Skip to content

Commit

Permalink
NEW LinkFieldController to handle FormSchema
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Oct 25, 2023
1 parent f0a3b25 commit 9eba08d
Show file tree
Hide file tree
Showing 10 changed files with 1,323 additions and 20 deletions.
1 change: 0 additions & 1 deletion _config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@

// Avoid creating global variables
call_user_func(function () {

});
2 changes: 1 addition & 1 deletion _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Name: linkfield

SilverStripe\Admin\LeftAndMain:
extensions:
- SilverStripe\LinkField\Extensions\LeftAndMain
- SilverStripe\LinkField\Extensions\LeftAndMainExtension

SilverStripe\Admin\ModalController:
extensions:
Expand Down
960 changes: 959 additions & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

69 changes: 68 additions & 1 deletion client/dist/styles/bundle.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions client/src/components/LinkField/LinkField.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { compose } from 'redux';
import { inject, injectGraphql, loadComponent } from 'lib/Injector';
import fieldHolder from 'components/FieldHolder/FieldHolder';

const LinkField = ({ id, loading, Loading, data, LinkPicker, onChange, types, linkDescription, ...props }) => {
const LinkField = ({ id, loading, Loading, data, LinkPicker, onChange, types, linkDescription, submitForm, ...props }) => {
if (loading) {
return <Loading />;
}
Expand All @@ -20,6 +20,8 @@ const LinkField = ({ id, loading, Loading, data, LinkPicker, onChange, types, li
};

const { typeKey } = data;
console.log(['data is', data]);
console.log(['typeKey is', typeKey]);
const type = types[typeKey];
const modalType = newTypeKey ? types[newTypeKey] : type;

Expand Down Expand Up @@ -51,7 +53,7 @@ const LinkField = ({ id, loading, Loading, data, LinkPicker, onChange, types, li
setEditing(false);
setNewTypeKey('');

return Promise.resolve();
return submitFn();
};

const modalProps = {
Expand All @@ -67,6 +69,8 @@ const LinkField = ({ id, loading, Loading, data, LinkPicker, onChange, types, li
const handlerName = modalType ? modalType.handlerName : 'FormBuilderModal';
const LinkModal = loadComponent(`LinkModal.${handlerName}`);

console.log(['linkProps is', linkProps]);

return <Fragment>
<LinkPicker {...linkProps} />
<LinkModal {...modalProps} />
Expand All @@ -81,6 +85,7 @@ const stringifyData = (Component) => (({ data, value, ...props }) => {
return <Component dataStr={JSON.stringify(dataValue)} {...props} data={dataValue} />;
});


export default compose(
inject(['LinkPicker', 'Loading']),
injectGraphql('readLinkTypes'),
Expand Down
8 changes: 7 additions & 1 deletion client/src/components/LinkModal/LinkModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ const buildSchemaUrl = (key, data) => {
const parsedQs = qs.parse(parsedURL.query);
parsedQs.key = key;
if (data) {
parsedQs.data = JSON.stringify(data);
// parsedQs.data = JSON.stringify(data);
// parsedQs.id = data.ID;
for (const prop of ['href', 'path', 'pathname']) {
parsedURL[prop] += '/' + data.ID;
}
// console.log(parsedURL);
// parsedURL += '/' +data.ID;
}
return url.format({ ...parsedURL, search: qs.stringify(parsedQs)});
}
Expand Down
Loading

0 comments on commit 9eba08d

Please sign in to comment.