Skip to content

Commit

Permalink
feat(entry-field-description): translate
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Oct 1, 2020
1 parent 31aaf37 commit 9afcc87
Show file tree
Hide file tree
Showing 61 changed files with 243 additions and 213 deletions.
2 changes: 1 addition & 1 deletion lib/factory/AutoSuggestTextBoxFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var SUGGESTION_LIST_BOX_THRESHOLD = 15;
var noop = function() {};


var autoSuggestTextBox = function(options, defaultParameters) {
var autoSuggestTextBox = function(translate, options, defaultParameters) {

var resource = defaultParameters,
label = options.label || resource.id,
Expand Down
4 changes: 2 additions & 2 deletions lib/factory/CheckboxEntryFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var getBusinessObject = require('bpmn-js/lib/util/ModelUtil').getBusinessObject,
var entryFieldDescription = require('./EntryFieldDescription');


var checkbox = function(options, defaultParameters) {
var checkbox = function(translate, options, defaultParameters) {
var resource = defaultParameters,
id = resource.id,
label = options.label || id,
Expand All @@ -31,7 +31,7 @@ var checkbox = function(options, defaultParameters) {

// add description below checkbox entry field
if (description) {
resource.html.appendChild(entryFieldDescription(description, { show: canBeHidden && 'isHidden' }));
resource.html.appendChild(entryFieldDescription(description, translate, { show: canBeHidden && 'isHidden' }));
}

resource.get = function(element) {
Expand Down
4 changes: 2 additions & 2 deletions lib/factory/ComboEntryFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var selectEntryFactory = require('./SelectEntryFactory'),
*
* @return {Object}
*/
var comboBox = function(options) {
var comboBox = function(translate, options) {

var selectOptions = options.selectOptions,
modelProperty = options.modelProperty,
Expand Down Expand Up @@ -116,7 +116,7 @@ var comboBox = function(options) {

// add description below combo box entry field
if (description) {
comboBoxEntry.html.appendChild(entryFieldDescription(description, { show: 'showCustomInput' }));
comboBoxEntry.html.appendChild(entryFieldDescription(description, translate, { show: 'showCustomInput' }));
}

return comboBoxEntry;
Expand Down
36 changes: 18 additions & 18 deletions lib/factory/EntryFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ function EntryFactory() {
* @param options
* @returns the propertyPanel entry resource object
*/
EntryFactory.textField = function(options) {
return textInputField(options, setDefaultParameters(options));
EntryFactory.textField = function(translate, options) {
return textInputField(translate, options, setDefaultParameters(options));
};

EntryFactory.validationAwareTextField = function(options) {
return validationAwareTextInputField(options, setDefaultParameters(options));
EntryFactory.validationAwareTextField = function(translate, options) {
return validationAwareTextInputField(translate, options, setDefaultParameters(options));
};

/**
Expand All @@ -134,36 +134,36 @@ EntryFactory.validationAwareTextField = function(options) {
* @param options
* @returns the propertyPanel entry resource object
*/
EntryFactory.checkbox = function(options) {
return checkboxField(options, setDefaultParameters(options));
EntryFactory.checkbox = function(translate, options) {
return checkboxField(translate, options, setDefaultParameters(options));
};

EntryFactory.textBox = function(options) {
return textBoxField(options, setDefaultParameters(options));
EntryFactory.textBox = function(translate, options) {
return textBoxField(translate, options, setDefaultParameters(options));
};

EntryFactory.selectBox = function(options) {
return selectBoxField(options, setDefaultParameters(options));
EntryFactory.selectBox = function(translate, options) {
return selectBoxField(translate, options, setDefaultParameters(options));
};

EntryFactory.comboBox = function(options) {
return comboBoxField(options);
EntryFactory.comboBox = function(translate, options) {
return comboBoxField(translate, options);
};

EntryFactory.table = function(options) {
return tableField(options);
EntryFactory.table = function(translate, options) {
return tableField(translate, options);
};

EntryFactory.label = function(options) {
return labelEntry(options);
};

EntryFactory.link = function(options) {
return link(options);
EntryFactory.link = function(translate, options) {
return link(translate, options);
};

EntryFactory.autoSuggest = function(options) {
return autoSuggestTextBoxField(options, setDefaultParameters(options));
EntryFactory.autoSuggest = function(translate, options) {
return autoSuggestTextBoxField(translate, options, setDefaultParameters(options));
};

EntryFactory.collapsible = function(options) {
Expand Down
6 changes: 3 additions & 3 deletions lib/factory/EntryFieldDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var MAX_DESCRIPTION_LENGTH = 200;
* @param {object} [options]
* @param {string} [options.show] - name of callback to determine whether description is shown
*/
module.exports = function entryFieldDescription(description, options) {
module.exports = function entryFieldDescription(description, translate, options) {
var show = options && options.show;

// we tokenize the description to extract text, HTML and markdown links
Expand Down Expand Up @@ -72,13 +72,13 @@ module.exports = function entryFieldDescription(description, options) {

descriptionText.textContent = description + ' ';

expand.textContent = 'Less';
expand.textContent = translate('Less');
} else {
domClasses(html).remove('description--expanded');

descriptionText.textContent = descriptionShortened + ' ... ';

expand.textContent = 'More';
expand.textContent = translate('More');
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/factory/LinkEntryFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var bind = require('lodash/bind');
*
* @return {Entry} the newly created entry
*/
function link(options) {
function link(translate, options) {

var id = options.id,
buttonLabel = options.buttonLabel || id,
Expand Down Expand Up @@ -72,7 +72,7 @@ function link(options) {

// add description below link entry field
if (description) {
resource.html.appendChild(entryFieldDescription(description, { show: 'showLink' }));
resource.html.appendChild(entryFieldDescription(description, translate, { show: 'showLink' }));
}

resource.handleClick = bind(handleClick, resource);
Expand Down
4 changes: 2 additions & 2 deletions lib/factory/SelectEntryFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var createOption = function(option) {
*
* @return {Object}
*/
var selectbox = function(options, defaultParameters) {
var selectbox = function(translate, options, defaultParameters) {
var resource = defaultParameters,
label = options.label || resource.id,
selectOptions = options.selectOptions || [ { name: '', value: '' } ],
Expand Down Expand Up @@ -80,7 +80,7 @@ var selectbox = function(options, defaultParameters) {

// add description below select box entry field
if (description && typeof options.showCustomInput !== 'function') {
resource.html.appendChild(entryFieldDescription(description, { show: canBeHidden && 'isHidden' }));
resource.html.appendChild(entryFieldDescription(description, translate, { show: canBeHidden && 'isHidden' }));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/factory/TableEntryFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function setSelection(node, selection) {
*
* @return {Object}
*/
module.exports = function(options) {
module.exports = function(translate, options) {

var id = options.id,
modelProperties = options.modelProperties,
Expand Down Expand Up @@ -172,7 +172,7 @@ module.exports = function(options) {
'</div>');

if (description) {
html.appendChild(entryFieldDescription(description, { show: 'showTable' }));
html.appendChild(entryFieldDescription(description, translate, { show: 'showTable' }));
}

var factory = {
Expand Down
4 changes: 2 additions & 2 deletions lib/factory/TextBoxEntryFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var escapeHTML = require('../Utils').escapeHTML;
var entryFieldDescription = require('./EntryFieldDescription');


var textBox = function(options, defaultParameters) {
var textBox = function(translate, options, defaultParameters) {

var resource = defaultParameters,
label = options.label || resource.id,
Expand All @@ -27,7 +27,7 @@ var textBox = function(options, defaultParameters) {

// add description below text box entry field
if (description) {
resource.html.appendChild(entryFieldDescription(description, { show: canBeShown && 'isShown' }));
resource.html.appendChild(entryFieldDescription(description, translate, { show: canBeShown && 'isShown' }));
}

if (canBeShown) {
Expand Down
4 changes: 2 additions & 2 deletions lib/factory/TextInputEntryFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var domify = require('min-dom').domify,
var entryFieldDescription = require('./EntryFieldDescription');


var textField = function(options, defaultParameters) {
var textField = function(translate, options, defaultParameters) {

// Default action for the button next to the input-field
var defaultButtonAction = function(element, inputNode) {
Expand Down Expand Up @@ -60,7 +60,7 @@ var textField = function(options, defaultParameters) {

// add description below text input entry field
if (description) {
resource.html.appendChild(entryFieldDescription(description, { show: canBeHidden && 'isHidden' }));
resource.html.appendChild(entryFieldDescription(description, translate, { show: canBeHidden && 'isHidden' }));
}

resource[actionName] = actionMethod;
Expand Down
4 changes: 2 additions & 2 deletions lib/factory/ValidationAwareTextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var textField = require('./TextInputEntryFactory');
* It adds functionality to cache an invalid value entered in the
* text input, instead of setting it on the business object.
*/
var validationAwareTextField = function(options, defaultParameters) {
var validationAwareTextField = function(translate, options, defaultParameters) {

var modelProperty = options.modelProperty;

Expand Down Expand Up @@ -50,7 +50,7 @@ var validationAwareTextField = function(options, defaultParameters) {
return options.validate(element, property, node);
};

return textField(options, defaultParameters);
return textField(translate, options, defaultParameters);
};

module.exports = validationAwareTextField;
4 changes: 2 additions & 2 deletions lib/provider/bpmn/parts/DocumentationProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = function(group, element, bpmnFactory, translate) {
};

// Element Documentation
var elementDocuEntry = entryFactory.textBox({
var elementDocuEntry = entryFactory.textBox(translate, {
id: 'documentation',
label: translate('Element Documentation'),
modelProperty: 'documentation'
Expand All @@ -56,7 +56,7 @@ module.exports = function(group, element, bpmnFactory, translate) {

// do not show for collapsed Pools/Participants
if (processRef) {
var processDocuEntry = entryFactory.textBox({
var processDocuEntry = entryFactory.textBox(translate, {
id: 'process-documentation',
label: translate('Process Documentation'),
modelProperty: 'documentation'
Expand Down
2 changes: 1 addition & 1 deletion lib/provider/bpmn/parts/ExecutableProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = function(group, element, translate) {

if (is(element, 'bpmn:Process') || (is(element, 'bpmn:Participant') && bo.get('processRef'))) {

var executableEntry = entryFactory.checkbox({
var executableEntry = entryFactory.checkbox(translate, {
id: 'process-is-executable',
label: translate('Executable'),
modelProperty: 'isExecutable'
Expand Down
2 changes: 1 addition & 1 deletion lib/provider/bpmn/parts/IdProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = function(group, element, translate, options) {
var description = options && options.description;

// Id
group.entries.push(entryFactory.validationAwareTextField({
group.entries.push(entryFactory.validationAwareTextField(translate, {
id: options.id || 'id',
label: translate('Id'),
description: description && translate(description),
Expand Down
2 changes: 1 addition & 1 deletion lib/provider/bpmn/parts/LinkProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = function(group, element, translate) {
var linkEventDefinition = getLinkEventDefinition(element);

if (linkEventDefinition) {
var entry = entryFactory.textField({
var entry = entryFactory.textField(translate, {
id: 'link-event',
label: translate('Link Name'),
modelProperty: 'link-name'
Expand Down
2 changes: 1 addition & 1 deletion lib/provider/bpmn/parts/ProcessProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function(group, element, translate, options) {
* processId
*/
if (is(element, 'bpmn:Participant')) {
var idEntry = entryFactory.validationAwareTextField({
var idEntry = entryFactory.validationAwareTextField(translate, {
id: 'process-id',
label: translate('Process Id'),
description: processIdDescription && translate(processIdDescription),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function createActivityRefOptions(element) {

module.exports = function(group, element, bpmnFactory, compensateEventDefinition, elementRegistry, translate) {

group.entries.push(entryFactory.checkbox({
group.entries.push(entryFactory.checkbox(translate, {
id: 'wait-for-completion',
label: translate('Wait for Completion'),
modelProperty: 'waitForCompletion',
Expand All @@ -104,7 +104,7 @@ module.exports = function(group, element, bpmnFactory, compensateEventDefinition
}
}));

group.entries.push(entryFactory.selectBox({
group.entries.push(entryFactory.selectBox(translate, {
id: 'activity-ref',
label: translate('Activity Ref'),
selectOptions: createActivityRefOptions(element),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = function(group, element, bpmnFactory, conditionalEventDefinitio
};
};

group.entries.push(entryFactory.textField({
group.entries.push(entryFactory.textField(translate, {
id: 'variableName',
label: translate('Variable Name'),
modelProperty : 'variableName',
Expand All @@ -41,7 +41,7 @@ module.exports = function(group, element, bpmnFactory, conditionalEventDefinitio
is(element, 'bpmn:StartEvent') && !isEventSubProcess(element.parent);

if (!isConditionalStartEvent) {
group.entries.push(entryFactory.textField({
group.entries.push(entryFactory.textField(translate, {
id: 'variableEvent',
label: translate('Variable Event'),
description: translate('Specify more than one variable change event as a comma separated list.'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ var cmdHelper = require('../../../../helper/CmdHelper');
*
* @return {Array<Object>} return an array containing the entries
*/
module.exports = function(element, definition, bpmnFactory, options) {
module.exports = function(element, definition, bpmnFactory, translate, options) {

var id = options.id || 'element-property';
var label = options.label;
var referenceProperty = options.referenceProperty;
var modelProperty = options.modelProperty || 'name';
var shouldValidate = options.shouldValidate || false;

var entry = entryFactory.textField({
var entry = entryFactory.textField(translate, {
id: id,
label: label,
modelProperty: modelProperty,
Expand Down
34 changes: 19 additions & 15 deletions lib/provider/bpmn/parts/implementation/ErrorEventDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,24 @@ module.exports = function(group, element, bpmnFactory, errorEventDefinition, tra
}));


group.entries = group.entries.concat(elementReferenceProperty(element, errorEventDefinition, bpmnFactory, {
id: 'error-element-name',
label: translate('Error Name'),
referenceProperty: 'errorRef',
modelProperty: 'name',
shouldValidate: true
}));


group.entries = group.entries.concat(elementReferenceProperty(element, errorEventDefinition, bpmnFactory, {
id: 'error-element-code',
label: translate('Error Code'),
referenceProperty: 'errorRef',
modelProperty: 'errorCode'
}));
group.entries = group.entries.concat(
elementReferenceProperty(element, errorEventDefinition, bpmnFactory, translate, {
id: 'error-element-name',
label: translate('Error Name'),
referenceProperty: 'errorRef',
modelProperty: 'name',
shouldValidate: true
})
);


group.entries = group.entries.concat(
elementReferenceProperty(element, errorEventDefinition, bpmnFactory, translate, {
id: 'error-element-code',
label: translate('Error Code'),
referenceProperty: 'errorRef',
modelProperty: 'errorCode'
})
);

};
Loading

0 comments on commit 9afcc87

Please sign in to comment.