Skip to content

Commit

Permalink
Enhancement move transform and other registration to separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Joe committed Aug 8, 2017
1 parent 6fa1585 commit fbf2ace
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 46 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_ssembed.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_sslink-file.js

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

2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_ssmedia.js

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

2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions client/src/boot/applyTransform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import i18n from 'i18n';
import Injector from 'lib/Injector';

const insertTransform = form => {
const schema = form.getState();
// todo remove this schemaName check when injector considers schemaName for selector
const schemaName = schema.schema.name;
if (schemaName !== 'fileInsertForm') {
return schema;
}
const overrides = schema.stateOverride && schema.stateOverride.fields;
const customTitle = (overrides && overrides.length > 0)
? i18n._t('AssetAdmin.UPDATE_FILE', 'Update file')
: i18n._t('AssetAdmin.INSERT_FILE', 'Insert file');

form.mutateField('action_insert', (field) => ({
...field,
title: customTitle || field.title,
}));

return form.getState();
};

const applyTransform = () => {
Injector.transform(
'insert-media-modal',
(updater) => {
updater.form.alterSchema('AssetAdmin.EditForm', insertTransform);
}
);
};

export default applyTransform;
Loading

0 comments on commit fbf2ace

Please sign in to comment.