UNPKG

processmaker-builder

Version:

The gulp task runner for ProcessMaker building

1,538 lines (1,450 loc) 143 kB
/** * Class representing a Web Entry * @param relatedShape * @constructor */ var WebEntry = function (relatedShape) { this.relatedShape = null; this.groupType = null; this.groupLabel = null; this.stepsType = null; this.actUid = null; this.evenUid = null; this.weeUid = null; this.stepsAssigned = null; this.elementAccordionOpen = null; this.configWebEntry = null; this.isNewWebEntry = null; this.windowWebEntry = null; this.windowAlternative = null; this.tabForm = null; this.tabProperties = null; this.tabLink = null; this.confirmWindow = null; this.tabPanelWindow = null; this.suggestUser = null; this.stepsAssignTree = null; this.stepsAssignAccordion = null; this.labelsPanel = null; this.userGuest = {}; WebEntry.prototype.initialize.call(this, relatedShape); }; /** * A module representing a Web Entry **/ WebEntry.prototype = { /** * Sets the actUid * @param {string} actUid */ setActUid: function (actUid) { this.actUid = actUid; return this; }, /** * Sets the evenUid * @param {string} evenUid */ setEvnUid: function (evenUid) { this.evenUid = evenUid; return this; }, /** * Sets the weeUid * @param {string} weeUid */ setWeeUid: function (weeUid) { this.weeUid = weeUid; return this; }, /** * Sets the configWebEntry * @param {object} configWebEntry */ setConfigWebEntry: function (configWebEntry) { this.configWebEntry = configWebEntry; return this; }, /** * Sets the isNewWebEntry * @param {boolean} isNewWebEntry */ setIsNewWebEntry: function (isNewWebEntry) { this.isNewWebEntry = isNewWebEntry; return this; }, /** * Sets the windowWebEntry * @param {object} windowWebEntry */ setWindowWebEntry: function (windowWebEntry) { this.windowWebEntry = windowWebEntry; return this; }, /** * Sets the windowAlternative * @param {object} windowAlternative */ setWindowAlternative: function (windowAlternative) { this.windowAlternative = windowAlternative; return this; }, /** * Sets the relatedShape * @param {object} relatedShape */ setRelatedShape: function (relatedShape) { this.relatedShape = relatedShape; return this; }, /** * Sets the tabForm * @param {object} tabForm */ setTabForm: function (tabForm) { this.tabForm = tabForm; return this; }, /** * Sets the tabProperties * @param {object} tabProperties */ setTabProperty: function (tabProperties) { this.tabProperties = tabProperties; return this; }, /** * Sets the tabLink * @param {object} tabLink */ setTabLink: function (tabLink) { this.tabLink = tabLink; return this; }, /** * Sets the confirmWindow * @param {object} confirmWindow */ setConfirmWin: function (confirmWindow) { this.confirmWindow = confirmWindow; return this; }, /** * Sets the tabPanelWindow * @param {object} tabPanelWindow */ setTabPanelWindow: function (tabPanelWindow) { this.tabPanelWindow = tabPanelWindow; return this; }, /** * Sets the suggestUser * @param {object} suggestUser */ setSuggestUser: function (suggestUser) { this.suggestUser = suggestUser; return this; }, /** * Sets the stepsAssignTree * @param {object} stepsAssignTree */ setStepsTree: function (stepsAssignTree) { this.stepsAssignTree = stepsAssignTree; return this; }, /** * Sets the stepsAssignAccordion * @param {object} stepsAssignAccordion */ setStepsAccordion: function (stepsAssignAccordion) { this.stepsAssignAccordion = stepsAssignAccordion; return this; }, /** * Sets the labelsPanel * @param {object} labelsPanel */ setLabelPanel: function (labelsPanel) { this.labelsPanel = labelsPanel; return this; }, /** * Sets the userGuest * @param userGuest */ setUserGuest: function (userGuest) { this.userGuest = userGuest; return this; }, /** * Get the userGuest * @returns {Object} userGuest */ getUserGuest: function () { return this.userGuest || {}; }, /** * Get the actUid value * @returns {null|*|string} The actUid value */ getActUid: function () { return this.actUid || ""; }, /** * Get the isNewWebEntry value * @returns {null|*|boolean} The isNewWebEntry value */ getRelatedShape: function () { return this.relatedShape || []; }, /** * Get the evenUid value * @returns {null|*|string} The evenUid value */ getEvnUid: function () { return this.evenUid || ""; }, /** * Get the weeUid value * @returns {null|*|string} The weeUid value */ getWeeUid: function () { return this.weeUid || ""; }, /** * Get the configWebEntry value * @returns {*|null|Array} The configWebEntry value */ getConfigWebEntry: function () { return this.configWebEntry || []; }, /** * Get the isNewWebEntry value * @returns {null|*|boolean} The isNewWebEntry value */ getIsNewWebEntry: function () { return this.isNewWebEntry || false; }, /** * Get the windowWebEntry value * @returns {null|*} The windowWebEntry value */ getWindowWebEntry: function () { return this.windowWebEntry || null; }, /** * Get the windowAlternative value * @returns {*|null} The windowAlternative value */ getWindowAlternative: function () { return this.windowAlternative || null; }, /** * Get the tabForm value * @returns {*|null} The tabForm value */ getTabForm: function () { return this.tabForm || null; }, /** * Get the tabProperties value * @returns {null|*} The tabProperties value */ getTabProperty: function () { return this.tabProperties || null; }, /** * Get the tablink value * @returns {null|*} The tablink value */ getTabLink: function () { return this.tabLink || null; }, /** * Get the confirmWindow value * @returns {null|*} The confirmWindow value */ getConfirmWin: function () { return this.confirmWindow || null; }, /** * Get the tabPanelWindow * @returns {*|null} */ getTabPanelWindow: function () { return this.tabPanelWindow || null; }, /** * get the suggestUser value * @returns {*|null} The suggestUser value */ getSuggestUser: function () { return this.suggestUser || null; }, /** * Sets the stepsAssignTree * @returns {*|null} */ getStepsTree: function () { return this.stepsAssignTree || null; }, /** * Get the stepsAssignAccordion value * @returns {*|null} The stepsAssignAccordion value */ getStepsAccordion: function () { return this.stepsAssignAccordion || null; }, /** * get the labelsPanel value * @returns {null|*} The labelsPanel value */ getLabelPanel: function () { return this.labelsPanel || null; }, /** * initialize App * @param relatedShape */ initialize: function (relatedShape) { this.groupType = [ 'DYNAFORM', 'INPUT_DOCUMENT', 'OUTPUT_DOCUMENT', 'EXTERNAL' ]; this.groupLabel = [ 'Dynaform (s)'.translate(), 'Input Document (s)'.translate(), 'OutPut Document (s)'.translate(), 'External (s)'.translate() ]; this.stepsType = { 'DYNAFORM': 'Dynaform'.translate(), 'INPUT_DOCUMENT': 'Input Document'.translate(), 'OUTPUT_DOCUMENT': 'Output Document'.translate(), 'EXTERNAL': 'External'.translate() }; this.setRelatedShape(relatedShape) .setEvnUid(relatedShape.evn_uid); if (this.getRelatedShape().getPorts().getFirst()) { this.setActUid(this.getRelatedShape().getPorts().getFirst().getConnection().getDestPort().getParent() .act_uid); } if (__env.USER_GUEST) { $.extend(true, this.userGuest, __env.USER_GUEST); } this.stepsAssigned = new PMUI.util.ArrayList(); this.elementAccordionOpen = new PMUI.util.ArrayList(); }, /** * Render form * @returns {WebEntry} */ render: function () { this.getWindow().addItem(this.getTabPanel()); this.getWindow().open(); this.getWindow().showFooter(); this.initializeData(); return this; }, /** * Populate Web Entry data */ initializeData: function () { //Pupulate web entry data this.getInstanceWebEntryData(); this.setWebEntryConfiguration(); this.initializeAccordionAndTreepanelData(); }, /** * Populate accordion and treepanel data */ initializeAccordionAndTreepanelData: function () { var that = this; //clear global array stepsAssigned this.stepsAssigned.clear(); //get accordion data this.getAccordionData( function (xhr, response) { //populate data accordion tabForms that.loadAccordionItems(response); }, function (xhr, response) { PMDesigner.msgWinError(response.error.message); } ); //get getTreePanelData data this.getTreePanelData( function (xhr, response) { //populate data treePanel tabForms that.loadTreePanelData(response); }, function (xhr, response) { PMDesigner.msgWinError(response.error.message); } ); this.addEventSortableInAccordionElements(); this.addEventSortableInTreePanelElements(); }, /** * Get all dynaforms * Execute restClient(GET/project/dynaforms) * @param successCallback * @param failureCallback */ getDynaforms: function (successCallback, failureCallback) { return new PMRestClient({ typeRequest: 'post', multipart: true, data: { calls: [ { url: 'dynaforms', method: 'GET' } ] }, functionSuccess: function (xhr, response) { successCallback(xhr, response); }, functionFailure: function (xhr, response) { failureCallback(xhr, response); } }).executeRestClient(); }, /** * Get users * Execute restClient(GET/users/uid_usr) * @param uidUser * @param successCallback * @param failureCallback */ getUserData: function (uidUser, successCallback, failureCallback) { return new PMRestClient({ typeRequest: 'post', multipart: true, data: { calls: [ { url: 'users/' + uidUser, method: 'GET' } ] }, functionSuccess: function (xhr, response) { successCallback(xhr, response); }, functionFailure: function (xhr, response) { failureCallback(xhr, response); }, messageError: 'There are problems getting the Steps, please try again.'.translate() }).setBaseEndPoint("").executeRestClient(); }, /** * Get WebEntry Configuration * Execute restClient(GET/web-entry-event/event/) * Execute restClient(POST/web-entry-event/) * @param successCallback * @returns {Array} */ getWebEntryConfiguration: function (successCallback) { var that = this, restProxy = new PMRestClient({ endpoint: 'web-entry-event/event/' + that.getEvnUid(), typeRequest: "get", functionSuccess: function (xhr, response) { successCallback(response, false); that.initializeSomeVariables(response, false); }, functionFailure: function (xhr, response) { restProxy = new PMRestClient({ endpoint: 'web-entry-event', typeRequest: "post", data: { act_uid: that.getActUid(), evn_uid: that.getEvnUid(), wee_title: that.getEvnUid(), we_type: "MULTIPLE", we_authentication: "LOGIN_REQUIRED", we_callback: "PROCESSMAKER", we_callback_url: "", we_show_in_new_case: "0", usr_uid: that.getUserGuest().uid || '' }, functionSuccess: function (xhr, response) { successCallback(response, true); that.initializeSomeVariables(response, true); }, functionFailure: function (xhr, response) { PMDesigner.msgWinError(response.error.message); } }); restProxy.executeRestClient(); } }); restProxy.executeRestClient(); return this; }, /** * Update data Web Entry Configuration * Execute restClient(PUT/web-entry-event/weeuid) * @param data * @param successCallback * @param failureCallback * @returns {PMRestClient} */ updateWebEntryConfiguration: function (data, successCallback, failureCallback) { return new PMRestClient({ endpoint: 'web-entry-event/' + this.weeUid, typeRequest: 'update', data: data, functionSuccess: function (xhr, response) { successCallback(xhr, response); }, functionFailure: function (xhr, response) { failureCallback(xhr, response); } }).executeRestClient(); }, /** * Get Accordion Data (Tab Forms) * Execute restClient(GET/steps, GET/step/triggers) * @returns {Array} */ getAccordionData: function (successCallback, failureCallback) { return new PMRestClient({ typeRequest: 'post', multipart: true, data: { calls: [ { url: 'activity/' + this.getConfigWebEntry().tas_uid + '/steps', method: 'GET' }, { url: 'activity/' + this.getConfigWebEntry().tas_uid + '/step/triggers', method: 'GET' } ] }, functionSuccess: function (xhr, response) { successCallback(xhr, response); }, functionFailure: function (xhr, response) { failureCallback(xhr, response); }, messageError: 'There are problems getting the Steps, please try again.'.translate() }).executeRestClient(); }, /** * Get TreePanel Data (TabForm) * Execute restClient(GET/available-steps GET/triggers) * @returns {Array} */ getTreePanelData: function (successCallback, failureCallback) { return new PMRestClient({ typeRequest: 'post', multipart: true, data: { calls: [ { url: 'activity/' + this.getConfigWebEntry().tas_uid + '/available-steps', method: 'GET' }, { url: 'triggers', method: 'GET' } ] }, functionSuccess: function (xhr, response) { successCallback(xhr, response); }, functionFailure: function (xhr, response) { failureCallback(xhr, response); } }).executeRestClient(); }, /** * Get steps Availables (TreePanel) * Execute restClient(GET/available-steps) * @param successCallback * @param failureCallback * @returns {Array} */ getStepAvailables: function (successCallback, failureCallback) { return new PMRestClient({ typeRequest: 'post', multipart: true, data: { calls: [ { url: 'activity/' + this.getConfigWebEntry().tas_uid + '/available-steps', method: 'GET' } ] }, functionSuccess: function (xhr, response) { successCallback(xhr, response); }, functionFailure: function (xhr, response) { failureCallback(xhr, response); } }).executeRestClient(); }, /** * Load Skin and Languages * Execute restClient(GET/system/languages GET/system/skins) * @returns {Array} */ getSkinLanguage: function (successCallback, failureCallback) { return new PMRestClient({ typeRequest: 'post', multipart: true, data: { calls: [ { url: 'system/languages', method: 'GET' }, { url: 'system/skins', method: 'GET' } ] }, functionSuccess: function (xhr, response) { successCallback(xhr, response); }, functionFailure: function (xhr, response) { failureCallback(xhr, response); }, messageError: 'There are problems getting the Steps, please try again.'.translate() }).setBaseEndPoint("").executeRestClient(); }, /** * Delete the WebEntry configuration. * @param successCallback * @param failureCallback */ deleteWebEntryConfiguration: function (successCallback, failureCallback) { return new PMRestClient({ endpoint: 'web-entry-event/' + this.weeUid, typeRequest: 'remove', functionSuccess: function (xhr, response) { successCallback(xhr, response); }, functionFailure: function (xhr, response) { failureCallback(xhr, response); } }).executeRestClient(); }, /** * Generate webEntry Link * @param weeUid * @param successCallback * @param failureCallback */ generateLink: function (weeUid, successCallback, failureCallback) { return new PMRestClient({ endpoint: 'web-entry-event/' + weeUid + '/generate-link', typeRequest: 'get', functionSuccess: function (xhr, response) { successCallback(xhr, response); }, functionFailure: function (xhr, response) { failureCallback(xhr, response); } }).executeRestClient(); }, /** * Creates an instance of the WebEntry class * @returns {null} */ getInstanceWebEntryData: function () { this.getWebEntryConfiguration( function (webEntryEvent, isNew) { if (isNew) { webEntryEvent.we_type = 'SINGLE'; webEntryEvent.we_authentication = 'ANONYMOUS'; webEntryEvent.wee_url = ''; webEntryEvent.wee_title = ''; } } ); return this; }, /** * Get Main Container Window * @returns {PMUI.ui.Window} */ getWindow: function () { if (this.getWindowWebEntry() === null) { this.setWindowWebEntry(this.buildWindow()); } return this.getWindowWebEntry(); }, /** * Build Window Container * @returns {PMUI.ui.Window} */ buildWindow: function () { var that = this; return new PMUI.ui.Window({ id: 'windowWebEntry', title: 'Web Entry'.translate(), height: DEFAULT_WINDOW_HEIGHT, width: DEFAULT_WINDOW_WIDTH, footerAlign: 'right', onBeforeClose: function () { if (that.isNewWebEntry) { that.deleteWebEntryConfiguration( function () { that.getWindow().close(); }, function (xhr, response) { PMDesigner.msgWinError(response.error.message); } ); } else { that.getWindow().close(); } that.getWindow().close(); }, buttonPanelPosition: 'bottom', buttonsPosition: 'right', buttons: [ { id: 'windowWebEntryButtonDelete', text: 'Delete'.translate(), handler: function () { that.handlerDeleteWebEntry(); }, buttonType: "error" }, { id: 'windowWebEntryButtonCancel', text: 'Cancel'.translate(), handler: function () { if (that.isNewWebEntry) { that.deleteWebEntryConfiguration( function () { that.getWindow().close(); }, function (xhr, response) { PMDesigner.msgWinError(response.error.message); } ); } else { that.getWindow().close(); } }, buttonType: "error" }, { id: 'windowWebEntryButtonSave', text: 'Save'.translate(), handler: function (e) { that.checkUserGuest('saveConfig'); }, buttonType: 'success' } ] }); }, /** * Return Second Window Container * @returns {PMUI.ui.Window} */ getWindowAlternativeForm: function () { if (this.getWindowAlternative() === null) { this.setWindowAlternative(this.buildWindowAlternative()); } return this.getWindowAlternative(); }, /** * Build Second Window Container * @returns {PMUI.ui.Window} */ buildWindowAlternative: function () { return new PMUI.ui.Window({ visibleFooter: true, title: 'Trigger'.translate(), footerAlign: 'right', footerItems: [{ text: "@@", id: "secondaryWindow-criteria", style: { cssProperties: { "background": "rgb(45, 62, 80)", "border": "1px solid rgb(45, 62, 80)" }, cssClasses: ["mafe-button-condition-trigger"] } }, { id: 'secondaryWindow-cancel', text: 'Cancel'.translate(), buttonType: 'error', height: 31, style: { cssClasses: ["mafe-button-condition-trigger"] } }, { id: 'secondaryWindow-save', text: 'Save'.translate(), buttonType: 'success', height: 31, style: { cssClasses: ["mafe-button-condition-trigger"] } }] }); }, /** * Get TabPanel Container * @returns {TabPanel} */ getTabPanel: function () { if (this.getTabPanelWindow() === null) { this.setTabPanelWindow(this.buildPanelWindow()); } return this.getTabPanelWindow(); }, /** * Build TabPanel (TabForms, TabProperties, TabLink) * @returns {PMUI.panel.TabPanel} */ buildPanelWindow: function () { return new PMUI.panel.TabPanel({ id: 'windowWebEntryTabPanel', width: DEFAULT_WINDOW_WIDTH - 50, items: [ { id: 'tabForms', title: 'Forms'.translate(), panel: this.getTabForms() }, { id: 'tabProperties', title: 'Properties'.translate(), panel: this.getTabProperties() }, { id: 'tabLink', title: 'Link'.translate(), panel: this.getTabLinkForm() } ], style: { cssProperties: { 'margin-left': '10px' } }, itemsPosition: { position: 'left' } }); }, /** * Get Panel TabForms * @returns {Panel} */ getTabForms: function () { if (this.getTabForm() === null) { this.setTabForm(this.buildTabForms()); } return this.getTabForm(); }, /** * Build Tab Forms * @returns {PMUI.core.Panel} */ buildTabForms: function () { var that = this, singleDynaform, stepsMainContainer; singleDynaform = new PMUI.form.Form({ id: 'singleDynaform', width: DEFAULT_WINDOW_WIDTH - 220, height: 180, name: 'singleDynaform', visibleHeader: false, items: [ { id: 'singleDynaformRadio', pmType: 'radio', labelVisible: false, value: 'SINGLE', name: 'options', required: false, controlPositioning: 'horizontal', maxDirectionOptions: 4, options: [ { id: 'singleDynaform', label: 'Single Dynaform'.translate(), value: 'SINGLE', selected: true } ], onChange: function (newVal, oldVal) { that.weeFormModeChange(newVal, oldVal); }, labelWidth: '0%' }, { id: 'weeSelectDynaform', name: 'tabFormsDropdownDyanform', pmType: 'dropdown', label: 'Dynaform'.translate(), helper: 'Select Dynaform use in case.'.translate(), required: true, controlsWidth: 400, labelWidth: '25%', style: { cssProperties: { 'padding-left': '100px' } }, options: [ { label: 'Select Dynaform'.translate(), value: '' } ] }, { id: 'multipleStepsRadio', pmType: 'radio', labelVisible: false, value: '', name: 'options', required: false, controlPositioning: 'vertical', maxDirectionOptions: 4, options: [ { id: 'multipleSteps', label: 'Multiple Steps'.translate(), value: 'MULTIPLE' } ], onChange: function (newVal, oldVal) { that.weeFormModeChange(newVal, oldVal); }, labelWidth: '0%' } ] }); stepsMainContainer = new PMUI.core.Panel({ id: 'stepsMainContainer', layout: 'hbox', width: DEFAULT_WINDOW_WIDTH - 220, items: [ that.getStepsAssignTree(), that.getStepsAssignAccordion() ] }); return new PMUI.core.Panel({ id: 'mainContainer', layout: 'vbox', width: DEFAULT_WINDOW_WIDTH - 220, items: [ singleDynaform, that.getLabelsPanel(), stepsMainContainer ] }); }, /** * Get Panel TabProperties * @returns {Panel} */ getTabProperties: function () { if (this.getTabProperty() === null) { this.setTabProperty(this.buildTabProperties()); } return this.getTabProperty(); }, /** * Build TabProperties * @returns {PMUI.core.Panel} */ buildTabProperties: function () { var that = this, propertiesForm; propertiesForm = new PMUI.form.Form({ id: 'idTabFormProperties', width: DEFAULT_WINDOW_WIDTH - 220, visibleHeader: false, items: [ { id: 'tabPropertiesWebEntryTitle', pmType: 'text', name: 'tabPropertiesWebEntryTitle', valueType: 'string', label: 'Web Entry Title'.translate(), placeholder: 'Enter a title displayed on web entry window (if applies)'.translate(), helper: 'Enter a title displayed on web entry window (if applies).'.translate(), required: false, controlsWidth: 458, labelWidth: '23%' }, { id: 'tabPropRadioAuthentication', pmType: 'radio', labelVisible: true, label: 'Authentication', value: 'ANONYMOUS', name: 'authentication', required: true, controlPositioning: 'horizontal', maxDirectionOptions: 4, options: [ { id: 'tabPropertiesOptionRadioAnonymous', label: 'Anonymous'.translate(), value: 'ANONYMOUS', selected: false } ], onChange: function (newVal, oldVal) { that.anonimusProcedure(newVal, oldVal); }, labelWidth: '23%' }, { id: 'tabPropertiesRequireUserLogin', pmType: 'radio', labelVisible: false, value: 'LOGIN_REQUIRED', required: false, name: 'authentication', controlPositioning: 'horizontal', maxDirectionOptions: 4, options: [ { id: 'tabPropertiesRadioRequireUserLogin', label: 'Require user login'.translate(), value: 'LOGIN_REQUIRED', selected: false } ], onChange: function (newVal, oldVal) { that.loginRequired(newVal, oldVal); }, labelWidth: '23%' }, { id: 'tabPropertiesHideLoogedInformationBar', pmType: 'checkbox', name: 'tabPropertiesHideLoogedInformationBar', labelVisible: false, disabled: true, options: [ { id: 'hideLoogedInformationBar', label: 'Hide Logged Information Bar'.translate(), value: '1', selected: false } ], style: { cssProperties: { 'padding-left': '50px' } } }, { id: 'tabPropertiesRadioCallback', pmType: 'radio', labelVisible: true, label: 'Callback Action', value: 'PROCESSMAKER', required: true, disabled: false, controlPositioning: 'vertical', labelPosition: 'left', helper: 'Callback Action...'.translate(), maxDirectionOptions: 4, options: [ { id: 'redirectPM', label: 'Redirect to ProcessMaker predefined response page'.translate(), value: 'PROCESSMAKER', selected: true }, { id: 'redirectURL', label: 'Redirect to custom URL'.translate(), value: 'CUSTOM' }, { id: 'redirectCustom', label: 'Redirect to custom URL and clear login info'.translate(), value: 'CUSTOM_CLEAR' } ], onChange: function (newVal, oldVal) { that.callbackActionChange(newVal, oldVal); }, labelWidth: '23%' }, new CriteriaField({ id: 'criteriaFieldCustomUrl', pmType: 'text', name: 'criteriaFieldCustomUrl', label: 'Custom URL'.translate(), placeholder: 'Enter a valid URL to be redirected when entry will be completed'.translate(), labelWidth: '23%', controlsWidth: 455, required: true, disabled: true }), { id: 'showInNewCase', pmType: 'checkbox', name: 'showInNewCase', label: 'Show task in New Case'.translate(), labelVisible: true, options: [ { id: 'showTaskInNewCase', value: 'showCase', selected: false } ], onChange: function (newValue, oldValue) { this.setValue(newValue); } } ] }); $(propertiesForm.getItem('tabPropRadioAuthentication').getHTML()) .append($(that.getSuggestField().createHTML())); return propertiesForm; }, /** * Get Panel TabLink * @returns {Panel} */ getTabLinkForm: function () { if (this.getTabLink() === null) { this.setTabLink(this.buildTabLink()); } return this.getTabLink(); }, /** * Build TabLink * @returns {PMUI.core.Panel} */ buildTabLink: function () { var that = this, tfromLink; tfromLink = new PMUI.form.Form({ id: 'idTabFormLink', width: DEFAULT_WINDOW_WIDTH - 220, visibleHeader: false, items: [ { id: 'tabLinkRadioGeneration', pmType: 'radio', labelVisible: true, label: 'Link Generation'.translate(), value: 'DEFAULT', name: 'options', required: true, controlPositioning: 'vertical', labelPosition: 'left', helper: 'Link Generation'.translate(), controlsWidth: 485, labelWidth: '24.5%', maxDirectionOptions: 3, options: [ { id: 'generateLinkDefaultValues', label: 'Generate link using workspace default values (skin, language)'.translate(), value: 'DEFAULT', selected: 'true' }, { id: 'advancedLinkGeneration', label: 'Advanced link generation'.translate(), value: 'ADVANCED' } ], onChange: function (newVal) { that.linkGenerationOnChange(newVal); }, labelWidth: '18%' }, { id: 'tabLinkDropdownSkin', name: 'tabLinkDropdownSkin', pmType: 'dropdown', label: 'Skin'.translate(), helper: 'Select a Skin.'.translate(), required: true, controlsWidth: 485, labelWidth: '24.5%', onChange: function () { that.setLinkText(tfromLink, ''); }, options: [ { label: 'Select a Skin'.translate(), value: '' } ] }, { id: 'tabLinkDropdownLanguage', name: 'tabLinkDropdownLanguage', pmType: 'dropdown', label: 'Language'.translate(), helper: 'Select a language.'.translate(), required: true, controlsWidth: 485, labelWidth: '24.5%', onChange: function () { that.setLinkText(tfromLink, ''); }, options: [ { label: 'Select a language'.translate(), value: '' } ] }, { id: 'tablinkTextCustomDomain', pmType: 'text', name: 'tablinkTextCustomDomain', valueType: 'string', label: 'Custom Hostname'.translate(), placeholder: 'https://example.com:8080'.translate(), helper: 'Protocol and Hostname, port is optional.'.translate(), required: true, controlsWidth: 485, labelWidth: "24.5%", validators: [ { pmType: "regexp", criteria: /^(https?:\/\/)?(((\d{1,3}\.){3}\d{1,3})|(([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?))(:\d+)?$/i, errorMessage: 'Enter a Protocol and Hostname valid value.'.translate() } ], onChange: function () { that.setLinkText(tfromLink, ''); } }, { id: 'panelLinkForm', pmType: 'panel', layout: 'hbox', required: true, width: '155px', style: { cssProperties: { 'margin-left': '-10px', 'margin-top': '-10px' } }, items: [ { pmType: 'annotation', text: 'Web Entry URL:'.translate(), id: 'webEntryLinkLabel', required: true, name: 'webEntryLinkLabel' }, { pmType: 'annotation', id: 'webEntryLink', name: 'webEntryLink', text: '', required: true, textType: 1, style: { cssProperties: { 'margin-left': '-173px' } } } ] }, new PMUI.field.ButtonField({ id: 'buttonFieldGenerateLink', pmType: 'buttonField', value: 'Generate Link'.translate(), labelVisible: false, buttonAlign: 'center', controlsWidth: 180, proportion: 0.6, handler: function (field) { that.checkUserGuest('generateLink'); }, buttonType: 'success', style: { cssProperties: { 'vertical-align': 'top', 'padding-top': '10px', 'padding-right': '0px', 'padding-bottom': '1px', 'padding-left': '130px' } } }) ] }); tfromLink.getItem('buttonFieldGenerateLink').getControl(0).button.setButtonType('success'); return tfromLink; }, /** * Get MessageWindow Container * @returns {PMUI.ui.MessageWindow} */ getConfirmWindow: function () { if (this.getConfirmWin() === null) { this.setConfirmWin(this.buildConfirmWindow()); } return this.getConfirmWin(); }, /** * Build MessageWindow * @returns {PMUI.ui.MessageWindow} */ buildConfirmWindow: function () { return new PMUI.ui.MessageWindow({ id: 'confirmWindowDeleteAcceptedValue', windowMessageType: 'warning', width: 490, bodyHeight: 'auto', title: '', message: '', footerItems: [ { id: 'confirmWindow-footer-no', text: 'No'.translate(), visible: true, buttonType: 'error' }, { id: 'confirmWindow-footer-yes', text: 'Yes'.translate(), visible: true, buttonType: 'success' } ], visibleFooter: true }); }, /** * Handler button for delete web entry config */ handlerDeleteWebEntry: function () { var that = this, confirmWindow, yesButton, noButton; confirmWindow = that.getConfirmWindow() .setMessage('Are you sure you want to delete the Web Entry configuration?'.translate()); yesButton = that.getConfirmWindow().footer.getItem('confirmWindow-footer-yes'); yesButton.setHandler(function () { confirmWindow.close(); that.deleteWebEntryConfiguration( function () { that.getWindow().close(); }, function (xhr, response) { PMDesigner.msgWinError(response.error.message); } ); }); noButton = that.getConfirmWindow().footer.getItem('confirmWindow-footer-no'); noButton.setHandler(function () { that.getConfirmWindow().close(); }); that.getConfirmWindow().open(); return this; }, /** * Handler button for save web entry config * @param method */ checkUserGuest: function (method) { var title = 'Web Entry Anonymous Authentication'.translate(), message = ('Current selected user to act as anonymous will be replaced by the Guest user. ' + 'This action cannot be undone. Do you want to proceed?').translate(); //Validate the data before saving the configuration or generate the link if (this.isValidWebEntryData(method)) { (method === 'saveConfig') ? this.handlerSaveButton(message, title) : this.handlerGenerateLinkButton(message, title); } return this; }, /** * Check userGuestUID and save Config * @param message * @param title * @returns {WebEntry} */ handlerSaveButton: function (message, title) { var that = this, messageWindow = this.getConfirmWindow(); //Validation is done to be compatible with older versions of webEntry (Now exist guest-type user). if (this.getUserGuest().uid && this.getSuggestField().value !== this.getUserGuest().uid) { messageWindow.setMessage(message); messageWindow.setTitle(title); //handler for cancel button messageWindow.footer.getItem('confirmWindow-footer-no').setHandler(function () { messageWindow.close(); }); //handler for yes button messageWindow.footer.getItem('confirmWindow-footer-yes').setHandler(function () { messageWindow.close(); that.getSuggestField().set('value', that.getUserGuest().uid); that.saveWebEntryConfiguration( function () { that.getWindow().close(); }, function (xhr, response) { PMDesigner.msgWinError(response.error.message); } ); }); messageWindow.open(); } else { //For new configurations we save the configuration without any GUEST user validation. this.saveWebEntryConfiguration( function () { that.getWindow().close(); }, function (xhr, response) { PMDesigner.msgWinError(response.error.message); } ); } return this; }, /** * Check userGuestUID and generate webEntry Link * @param message * @param title * @returns {WebEntry} */ handlerGenerateLinkButton: function (message, title) { var that = this, formLink = this.getTabLinkForm(), messageWindow = this.getConfirmWindow(); //Validation is done to be compatible with older versions of webEntry (Now exist guest-type user). if (this.getUserGuest().uid && this.getSuggestField().value !== this.getUserGuest().uid) { messageWindow.setMessage(message); messageWindow.setTitle(title); //handler for cancel button messageWindow.footer.getItem('confirmWindow-footer-no').setHandler(function () { messageWindow.close(); }); //handler for yes button messageWindow.footer.getItem('confirmWindow-footer-yes').setHandler(function () { messageWindow.close(); that.getSuggestField().set('value', that.getUserGuest().uid); that.setLinkText(formLink, ''); //save Web Entry Configuration that.saveWebEntryConfiguration( function (xhr, response) { that.getConfigWebEntry().usr_uid = response.usr_uid || that.getConfigWebEntry().usr_uid; //generate webEntry Link that.generateLink( that.getWeeUid(), function (xhr, response) { that.setLinkText(formLink, (response.link) ? response.link : '');