Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPS-70099 BuildLang #50

Closed
wants to merge 11 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ AUI.add(
NAME: 'liferay-ddl-form-builder-action',

prototype: {
conditionChange: function() {},

getFieldsByType: function(type) {
var instance = this;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
AUI.add(
'liferay-ddl-form-builder-action-jump-to-page',
function(A) {
var Lang = A.Lang;

var TPL_ACTION_FIELD_LABEL = '<label class="lfr-ddm-form-field-container-inline">{message}</label>';

var FormBuilderActionJumpToPage = A.Component.create(
{
ATTRS: {
Expand All @@ -20,11 +16,8 @@ AUI.add(
value: []
},

strings: {
value: {
from: Liferay.Language.get('from'),
to: Liferay.Language.get('to')
}
type: {
value: 'jump-to-page'
}
},

Expand All @@ -35,6 +28,17 @@ AUI.add(
NAME: 'liferay-ddl-form-builder-action-jump-to-page',

prototype: {
conditionChange: function(pages) {
var instance = this;

var startIndex = pages[pages.length - 1] + 1;

var options = instance.get('options').slice(startIndex);

instance._setSourcePage(String(Math.max(pages)));
instance._setTargetOptions(options);
},

getValue: function() {
var instance = this;

Expand All @@ -48,33 +52,14 @@ AUI.add(
render: function() {
var instance = this;

var strings = instance.get('strings');

var index = instance.get('index');

var fieldsListContainer = instance.get('boundingBox').one('.target-' + index);

fieldsListContainer.append(instance._createLabel(strings.from));
instance._createSourceField().render(fieldsListContainer);
fieldsListContainer.append(instance._createLabel(strings.do));
instance._createTargetField().render(fieldsListContainer);
},

_createLabel: function(text) {
var instance = this;

var label = A.Node.create(
Lang.sub(
TPL_ACTION_FIELD_LABEL,
{
message: text
}
)
);

return label;
},

_createSourceField: function() {
var instance = this;

Expand All @@ -100,7 +85,7 @@ AUI.add(
options: instance.get('options'),
showLabel: false,
value: value,
visible: true
visible: false
}
);

Expand Down Expand Up @@ -141,6 +126,18 @@ AUI.add(
instance._targetField.get('container').addClass('lfr-ddm-form-field-container-inline');

return instance._targetField;
},

_setSourcePage: function(pageIndex) {
var instance = this;

instance._sourceField.setValue(String(pageIndex));
},

_setTargetOptions: function(pages) {
var instance = this;

instance._targetField.set('options', pages);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ AUI.add(
instance.after('pagesChange', A.bind(instance._afterPagesChange, instance));

instance.on('*:valueChange', A.bind(instance._handleActionChange, instance));

instance.on('*:valueChange', A.bind(instance._handleActionUpdates, instance));
},

render: function(rule) {
Expand Down Expand Up @@ -196,12 +198,14 @@ AUI.add(

var target = instance._actionFactory.createAction(type, index, action, container);

target.render(container);

target.conditionChange(instance._getConditionSelectedFieldsPage());

if (action && action.target) {
target.set('value', action.target);
}

target.render(container);

instance._actions[index + '-action'] = target;
},

Expand Down Expand Up @@ -252,6 +256,24 @@ AUI.add(
return actions;
},

_getConditionSelectedFieldsPage: function() {
var instance = this;

var fields = [];

for (var conditionKey in instance._conditions) {
if (!!conditionKey.match('-condition-second-operand-select') || !!conditionKey.match('-condition-first-operand')) {
var fieldName = instance._conditions[conditionKey].getValue();

if (fieldName) {
fields.push(instance._getFieldPageIndex(fieldName));
}
}
}

return fields;
},

_getFieldDataType: function(fieldName) {
var instance = this;

Expand All @@ -264,6 +286,18 @@ AUI.add(
return field.dataType;
},

_getFieldPageIndex: function(fieldName) {
var instance = this;

var field = instance.get('fields').find(
function(field) {
return field.value === fieldName;
}
);

return field.pageIndex;
},

_getOptionsLabel: function(field, optionValue) {
var instance = this;

Expand Down Expand Up @@ -308,6 +342,26 @@ AUI.add(
}
},

_handleActionUpdates: function(event) {
var instance = this;

var field = event.target;

var fieldName = field.get('fieldName');

if (field.getValue() &&
(fieldName.match('-condition-first-operand') ||
fieldName.match('-condition-second-operand-select'))) {
for (var key in instance._actions) {
var action = instance._actions[key];

if (key.match('-action') && action.get('type') === 'jump-to-page') {
action.conditionChange(instance._getConditionSelectedFieldsPage());
}
}
}
},

_handleAddActionClick: function() {
var instance = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ AUI.add(
var MAP_ACTION_DESCRIPTIONS = {
'auto-fill': 'auto-fill',
enable: 'enable-field',
'jump-to-page': 'jump-from-page-to-page',
'jump-to-page': 'jump-to-page',
require: 'require-field',
show: 'show-field'
};
Expand Down Expand Up @@ -47,7 +47,7 @@ AUI.add(
emptyListText: Liferay.Language.get('there-are-no-rules-yet-click-on-plus-icon-below-to-add-the-first'),
'enable-field': Liferay.Language.get('enable-x'),
'equals-to': Liferay.Language.get('is-equal-to'),
'jump-from-page-to-page': Liferay.Language.get('jump-from-x-to-x'),
'jump-to-page': Liferay.Language.get('jump-to-page-x'),
'not-contains': Liferay.Language.get('does-not-contain'),
'not-equals-to': Liferay.Language.get('is-not-equal-to'),
'require-field': Liferay.Language.get('require-x'),
Expand Down Expand Up @@ -133,6 +133,7 @@ AUI.add(
dataType: field.get('dataType'),
label: field.get('label') || field.get('fieldName'),
options: field.get('options'),
pageIndex: instance.getPageIndex(field),
type: field.get('type'),
value: field.get('fieldName')
}
Expand All @@ -143,6 +144,36 @@ AUI.add(
return fields;
},

getPageIndex: function(field) {
var instance = this;

var formBuilder = instance.get('formBuilder');

var layouts = formBuilder.get('layouts');

for (var h = 0; h < layouts.length; h++) {
var rows = layouts[h].get('rows');

for (var i = 0; i < rows.length; i++) {
var cols = rows[i].get('cols');

for (var j = 0; j < cols.length; j++) {
var fieldList = cols[j].get('value');

if (fieldList) {
var fields = fieldList.get('fields');

for (var k = 0; k < fields.length; k++) {
if (fields[k].get('label') === field.get('label')) {
return h;
}
}
}
}
}
}
},

getPages: function() {
var instance = this;

Expand Down Expand Up @@ -242,11 +273,6 @@ AUI.add(

if (type === 'jump-to-page') {
data = [
badgeTemplate(
{
content: pages[action.source].label
}
),
badgeTemplate(
{
content: pages[action.target].label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ is-less-than-or-equal-to=Is less than or equal to
is-not-equal-to=Is not equal to
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormAdminPortlet=Forms
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormPortlet=Form
jump-from-x-to-x=Jump from page {0} to {1}
jump-to-page=Jump to Page
jump-to-page-x=Jump to page {0}
leave-form=Leave form?
model.resource.com.liferay.dynamic.data.lists.model.DDLFormRecord=Form Record
move-field=Move Field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ is-less-than-or-equal-to=أقل من أو يساوي (Automatic Translation)
is-not-equal-to=لا يساوي (Automatic Translation)
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormAdminPortlet=أشكال (Automatic Translation)
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormPortlet=النموذج (Automatic Translation)
jump-from-x-to-x=Jump from page {0} to {1} (Automatic Copy)
jump-to-page=الانتقال إلى الصفحة (Automatic Translation)
jump-to-page-x=Jump to page {0} (Automatic Copy)
leave-form=ترك النموذج؟ (Automatic Translation)
model.resource.com.liferay.dynamic.data.lists.model.DDLFormRecord=سجل النموذج (Automatic Translation)
move-field=تحريك الحقل (Automatic Translation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ is-less-than-or-equal-to=По-малко или равно на (Automatic Trans
is-not-equal-to=Не е равно на (Automatic Translation)
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormAdminPortlet=Формуляри (Automatic Translation)
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormPortlet=Формуляр (Automatic Translation)
jump-from-x-to-x=Jump from page {0} to {1} (Automatic Copy)
jump-to-page=Направо към страница (Automatic Translation)
jump-to-page-x=Jump to page {0} (Automatic Copy)
leave-form=Оставете формата? (Automatic Translation)
model.resource.com.liferay.dynamic.data.lists.model.DDLFormRecord=Формуляр за запис (Automatic Translation)
move-field=Преместване на поле (Automatic Translation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ is-less-than-or-equal-to=És inferior o igual a (Automatic Translation)
is-not-equal-to=No és igual a (Automatic Translation)
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormAdminPortlet=Formes (Automatic Translation)
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormPortlet=Formulari
jump-from-x-to-x=Jump from page {0} to {1} (Automatic Copy)
jump-to-page=Saltar a pàgina (Automatic Translation)
jump-to-page-x=Jump to page {0} (Automatic Copy)
leave-form=Forma de deixar? (Automatic Translation)
model.resource.com.liferay.dynamic.data.lists.model.DDLFormRecord=Registre del formulari
move-field=Desplaça el camp (Automatic Translation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ is-less-than-or-equal-to=Je menší než nebo rovno (Automatic Translation)
is-not-equal-to=Není rovno (Automatic Translation)
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormAdminPortlet=Formuláře (Automatic Translation)
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormPortlet=Forma (Automatic Translation)
jump-from-x-to-x=Jump from page {0} to {1} (Automatic Copy)
jump-to-page=Přejít na stránku (Automatic Translation)
jump-to-page-x=Jump to page {0} (Automatic Copy)
leave-form=Opustit formulář? (Automatic Translation)
model.resource.com.liferay.dynamic.data.lists.model.DDLFormRecord=Záznam formuláře (Automatic Translation)
move-field=Přesunout pole (Automatic Translation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ is-less-than-or-equal-to=Is less than or equal to (Automatic Copy)
is-not-equal-to=Is not equal to (Automatic Copy)
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormAdminPortlet=Forms (Automatic Copy)
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormPortlet=Form (Automatic Translation)
jump-from-x-to-x=Jump from page {0} to {1} (Automatic Copy)
jump-to-page=Jump to Page (Automatic Copy)
jump-to-page-x=Jump to page {0} (Automatic Copy)
leave-form=Leave form? (Automatic Copy)
model.resource.com.liferay.dynamic.data.lists.model.DDLFormRecord=Formen Record (Automatic Translation)
move-field=Move Field (Automatic Copy)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ is-less-than-or-equal-to=Is less than or equal to (Automatic Copy)
is-not-equal-to=Is not equal to (Automatic Copy)
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormAdminPortlet=Forms (Automatic Copy)
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormPortlet=Formulare
jump-from-x-to-x=Jump from page {0} to {1} (Automatic Copy)
jump-to-page=Jump to Page (Automatic Copy)
jump-to-page-x=Jump to page {0} (Automatic Copy)
leave-form=Leave form? (Automatic Copy)
model.resource.com.liferay.dynamic.data.lists.model.DDLFormRecord=Formulare, Datensatz
move-field=Move Field (Automatic Copy)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ is-less-than-or-equal-to=Είναι μικρότερη από ή ίση με (Au
is-not-equal-to=Δεν είναι ίσο με (Automatic Translation)
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormAdminPortlet=Έντυπα (Automatic Translation)
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormPortlet=Μορφή (Automatic Translation)
jump-from-x-to-x=Jump from page {0} to {1} (Automatic Copy)
jump-to-page=Μετάβαση στη σελίδα (Automatic Translation)
jump-to-page-x=Jump to page {0} (Automatic Copy)
leave-form=Αφήστε τη φόρμα; (Automatic Translation)
model.resource.com.liferay.dynamic.data.lists.model.DDLFormRecord=Φόρμα εγγραφής (Automatic Translation)
move-field=Μετακίνηση πεδίου (Automatic Translation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ is-less-than-or-equal-to=Is less than or equal to
is-not-equal-to=Is not equal to
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormAdminPortlet=Forms
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormPortlet=Form
jump-from-x-to-x=Jump from page {0} to {1}
jump-to-page=Jump to Page
jump-to-page-x=Jump to page {0}
leave-form=Leave form?
model.resource.com.liferay.dynamic.data.lists.model.DDLFormRecord=Form Record
move-field=Move Field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ is-less-than-or-equal-to=Es menor o igual a (Automatic Translation)
is-not-equal-to=No es igual a (Automatic Translation)
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormAdminPortlet=Formularios
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormPortlet=Formulario
jump-from-x-to-x=Jump from page {0} to {1} (Automatic Copy)
jump-to-page=Salte a la página (Automatic Translation)
jump-to-page-x=Jump to page {0} (Automatic Copy)
leave-form=¿Deje el formulario? (Automatic Translation)
model.resource.com.liferay.dynamic.data.lists.model.DDLFormRecord=Registro del formulario
move-field=Mover campo (Automatic Translation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ is-less-than-or-equal-to=On väiksem või võrdne (Automatic Translation)
is-not-equal-to=Ei võrdu (Automatic Translation)
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormAdminPortlet=Vormid (Automatic Translation)
javax.portlet.title.com_liferay_dynamic_data_lists_form_web_portlet_DDLFormPortlet=Vorm (Automatic Translation)
jump-from-x-to-x=Jump from page {0} to {1} (Automatic Copy)
jump-to-page=Leheküljele liikumiseks (Automatic Translation)
jump-to-page-x=Jump to page {0} (Automatic Copy)
leave-form=Jäta vorm? (Automatic Translation)
model.resource.com.liferay.dynamic.data.lists.model.DDLFormRecord=Vormi kirje (Automatic Translation)
move-field=Teisaldage väli (Automatic Translation)
Expand Down