Index: ivy.xml =================================================================== --- ivy.xml (revision 32275) +++ ivy.xml (working copy) @@ -43,6 +43,6 @@ - + Index: main/plugin-thesaurus/i18n/messages_en.xml =================================================================== --- main/plugin-thesaurus/i18n/messages_en.xml (revision 32275) +++ main/plugin-thesaurus/i18n/messages_en.xml (working copy) @@ -208,6 +208,7 @@ An error occurred: the microthesaurus has not been created An error occurred: the microthesaurus has not been renamed New term ... + New term Modify Title An error occurred: the term has not been created Index: main/plugin-thesaurus/i18n/messages_fr.xml =================================================================== --- main/plugin-thesaurus/i18n/messages_fr.xml (revision 32275) +++ main/plugin-thesaurus/i18n/messages_fr.xml (working copy) @@ -208,6 +208,7 @@ Une erreur est survenue: le microthésaurus n'a pas été créé. Une erreur est survenue : le microthésaurus n'a pas été renommé Nouveau terme ... + Nouveau terme Modifier Titre Une erreur est survenue: le terme n'a pas été créé Index: main/plugin-thesaurus/plugin.xml =================================================================== --- main/plugin-thesaurus/plugin.xml (revision 32275) +++ main/plugin-thesaurus/plugin.xml (working copy) @@ -23,7 +23,7 @@ - @@ -95,8 +95,8 @@ + point="org.ametys.core.ui.StaticFileImportsManager" + class="org.ametys.core.ui.StaticFileImportsClientSideElement"> js/Ametys/plugins/thesaurus/TermMessageTarget.js @@ -107,13 +107,13 @@ + point="org.ametys.core.ui.MessageTargetFactoriesManager" + class="org.ametys.core.ui.StaticClientSideElement"> thesaurus-candidate - js/Ametys/plugins/cms/content/ContentMessageTargetFactory.i18n.js + js/Ametys/plugins/cms/content/ContentMessageTargetFactory.js @@ -269,10 +269,10 @@ + point="org.ametys.core.ui.StaticFileImportsManager" + class="org.ametys.core.ui.StaticFileImportsClientSideElement"> - js/Ametys/plugins/thesaurus/tool/ThesaurusTreePanel.i18n.js + js/Ametys/plugins/thesaurus/tool/ThesaurusTreePanel.js @@ -281,8 +281,8 @@ + point="org.ametys.core.ui.widgets.WidgetsManager" + class="org.ametys.core.ui.widgets.StaticClientSideWidget"> content false @@ -291,11 +291,11 @@ true - js/Ametys/cms/form/widget/SelectContent.i18n.js + js/Ametys/cms/form/widget/SelectContent.js js/Ametys/plugins/thesaurus/form/widget/SelectTerm/ContentEntry.js - js/Ametys/plugins/thesaurus/form/widget/SelectTerm.i18n.js - js/Ametys/plugins/thesaurus/helper/EditCandidateHelper.i18n.js - js/Ametys/plugins/thesaurus/helper/ChooseTermHelper.i18n.js + js/Ametys/plugins/thesaurus/form/widget/SelectTerm.js + js/Ametys/plugins/thesaurus/helper/EditCandidateHelper.js + js/Ametys/plugins/thesaurus/helper/ChooseTermHelper.js css/term.css @@ -303,8 +303,8 @@ + point="org.ametys.core.ui.widgets.WidgetsManager" + class="org.ametys.core.ui.widgets.StaticClientSideWidget"> sub_content false @@ -313,9 +313,9 @@ true - js/Ametys/cms/form/widget/SelectContent.i18n.js - js/Ametys/cms/form/widget/ComposeContent.i18n.js - js/Ametys/plugins/thesaurus/form/widget/ComposeTerm.i18n.js + js/Ametys/cms/form/widget/SelectContent.js + js/Ametys/cms/form/widget/ComposeContent.js + js/Ametys/plugins/thesaurus/form/widget/ComposeTerm.js @@ -332,7 +332,7 @@ - @@ -347,8 +347,8 @@ + point="org.ametys.core.ui.RibbonControlsManager" + class="org.ametys.core.ui.StaticClientSideElement"> Ametys.plugins.thesaurus.ThesaurusActions.createThesaurus @@ -360,15 +360,15 @@ img/actions/add_thesaurus_48.png - js/Ametys/plugins/thesaurus/ThesaurusActions.i18n.js - js/Ametys/plugins/thesaurus/helper/EditLabelDialogBox.i18n.js + js/Ametys/plugins/thesaurus/ThesaurusActions.js + js/Ametys/plugins/thesaurus/helper/EditLabelDialogBox.js Thesaurus_Rights_CreateThesaurus + point="org.ametys.core.ui.RibbonControlsManager" + class="org.ametys.core.ui.StaticClientSideElement"> Ametys.plugins.thesaurus.ThesaurusActions.renameThesaurus ^thesaurus$ @@ -379,15 +379,15 @@ img/actions/rename_thesaurus_48.png - js/Ametys/plugins/thesaurus/ThesaurusActions.i18n.js - js/Ametys/plugins/thesaurus/helper/EditLabelDialogBox.i18n.js + js/Ametys/plugins/thesaurus/ThesaurusActions.js + js/Ametys/plugins/thesaurus/helper/EditLabelDialogBox.js Thesaurus_Rights_EditThesaurus + point="org.ametys.core.ui.RibbonControlsManager" + class="org.ametys.core.ui.StaticClientSideElement"> Ametys.plugins.thesaurus.ThesaurusActions.deleteThesaurus ^thesaurus$ @@ -398,13 +398,13 @@ img/actions/delete_thesaurus_48.png - js/Ametys/plugins/thesaurus/ThesaurusActions.i18n.js + js/Ametys/plugins/thesaurus/ThesaurusActions.js Thesaurus_Rights_EditThesaurus @@ -423,14 +423,14 @@ - js/Ametys/plugins/thesaurus/ThesaurusActions.i18n.js - js/Ametys/plugins/thesaurus/controller/ThesaurusGalleryController.i18n.js + js/Ametys/plugins/thesaurus/ThesaurusActions.js + js/Ametys/plugins/thesaurus/controller/ThesaurusGalleryController.js Thesaurus_Rights_AccessThesaurus Ametys.plugins.thesaurus.tool.ThesaurusTool @@ -444,10 +444,10 @@ l - js/Ametys/plugins/thesaurus/tool/TermEntry.i18n.js - js/Ametys/plugins/thesaurus/tool/MicrothesaurusEntry.i18n.js - js/Ametys/plugins/thesaurus/tool/ThesaurusTool.i18n.js - js/Ametys/plugins/thesaurus/helper/EditCandidateHelper.i18n.js + js/Ametys/plugins/thesaurus/tool/TermEntry.js + js/Ametys/plugins/thesaurus/tool/MicrothesaurusEntry.js + js/Ametys/plugins/thesaurus/tool/ThesaurusTool.js + js/Ametys/plugins/thesaurus/helper/EditCandidateHelper.js css/thesaurus.css @@ -459,8 +459,8 @@ + point="org.ametys.core.ui.UIToolsFactoriesManager" + class="org.ametys.core.ui.StaticClientSideElement"> Ametys.plugins.thesaurus.tool.IndexedContentsTool uitool-indexed-contents @@ -474,7 +474,7 @@ - js/Ametys/plugins/thesaurus/tool/IndexedContentsTool.i18n.js + js/Ametys/plugins/thesaurus/tool/IndexedContentsTool.js css/search.css @@ -487,8 +487,8 @@ + point="org.ametys.core.ui.UIToolsFactoriesManager" + class="org.ametys.core.ui.StaticClientSideElement"> Ametys.plugins.thesaurus.tool.SearchIndexedContentsTool uitool-search-indexed-contents @@ -503,8 +503,8 @@ js/Ametys/plugins/cms/content/tool/ContentGridHelper.js - js/Ametys/plugins/cms/search/SearchTool.i18n.js - js/Ametys/plugins/thesaurus/tool/SearchIndexedContentsTool.i18n.js + js/Ametys/plugins/cms/search/SearchTool.js + js/Ametys/plugins/thesaurus/tool/SearchIndexedContentsTool.js css/search.css @@ -526,8 +526,8 @@ + point="org.ametys.core.ui.RibbonTabsManager" + class="org.ametys.core.ui.StaticClientSideElement"> ^(thesaurus|microthesaurus|content)$ ^(org.ametys.plugins.thesaurus.Content.candidate|org.ametys.plugins.thesaurus.Content.term)$ @@ -535,8 +535,8 @@ + point="org.ametys.core.ui.RibbonControlsManager" + class="org.ametys.core.ui.StaticClientSideElement"> Ametys.plugins.thesaurus.ThesaurusActions.createMicrothesaurus ^thesaurus$ @@ -549,15 +549,15 @@ img/actions/add_mt_48.png - js/Ametys/plugins/thesaurus/ThesaurusActions.i18n.js - js/Ametys/plugins/thesaurus/helper/EditLabelDialogBox.i18n.js + js/Ametys/plugins/thesaurus/ThesaurusActions.js + js/Ametys/plugins/thesaurus/helper/EditLabelDialogBox.js Thesaurus_Rights_EditMicrothesaurus + point="org.ametys.core.ui.RibbonControlsManager" + class="org.ametys.core.ui.StaticClientSideElement"> Ametys.plugins.thesaurus.ThesaurusActions.editMicrothesaurus ^thesaurus$ @@ -571,15 +571,15 @@ img/actions/rename_mt_48.png - js/Ametys/plugins/thesaurus/ThesaurusActions.i18n.js - js/Ametys/plugins/thesaurus/helper/EditLabelDialogBox.i18n.js + js/Ametys/plugins/thesaurus/ThesaurusActions.js + js/Ametys/plugins/thesaurus/helper/EditLabelDialogBox.js Thesaurus_Rights_EditMicrothesaurus + point="org.ametys.core.ui.RibbonControlsManager" + class="org.ametys.core.ui.StaticClientSideElement"> Ametys.plugins.thesaurus.ThesaurusActions.deleteMicrothesaurus ^thesaurus$ @@ -593,14 +593,14 @@ img/actions/delete_mt_48.png - js/Ametys/plugins/thesaurus/ThesaurusActions.i18n.js + js/Ametys/plugins/thesaurus/ThesaurusActions.js Thesaurus_Rights_EditMicrothesaurus + point="org.ametys.core.ui.RibbonControlsManager" + class="org.ametys.core.ui.StaticClientSideElement"> Ametys.plugins.thesaurus.ThesaurusActions.createTerm ^thesaurus$ @@ -615,14 +615,14 @@ img/actions/add_term_48.png - js/Ametys/plugins/thesaurus/ThesaurusActions.i18n.js - js/Ametys/plugins/thesaurus/helper/EditLabelDialogBox.i18n.js + js/Ametys/plugins/thesaurus/ThesaurusActions.js + js/Ametys/plugins/thesaurus/helper/EditLabelDialogBox.js Thesaurus_Rights_AddTerm + point="org.ametys.core.ui.RibbonControlsManager" + class="org.ametys.core.ui.StaticClientSideElement"> Ametys.plugins.thesaurus.ThesaurusActions.openTerm ^thesaurus$ @@ -637,11 +637,11 @@ img/actions/open_term_48.png - js/Ametys/plugins/thesaurus/ThesaurusActions.i18n.js + js/Ametys/plugins/thesaurus/ThesaurusActions.js Ametys.plugins.thesaurus.ThesaurusActions.editTerm @@ -682,12 +682,12 @@ js/Ametys/plugins/cms/content/controller/SmartContentController.js - js/Ametys/plugins/thesaurus/ThesaurusActions.i18n.js + js/Ametys/plugins/thesaurus/ThesaurusActions.js Thesaurus_Rights_EditTerm Ametys.plugins.cms.content.actions.UnlockOrLockContentAction.act @@ -733,12 +733,12 @@ js/Ametys/plugins/cms/content/controller/LockController.js - js/Ametys/plugins/cms/content/actions/UnlockOrLockContentAction.i18n.js + js/Ametys/plugins/cms/content/actions/UnlockOrLockContentAction.js @@ -773,7 +773,7 @@ js/Ametys/plugins/cms/content/controller/SmartContentController.js - js/Ametys/plugins/thesaurus/DeleteTermAction.i18n.js + js/Ametys/plugins/thesaurus/DeleteTermAction.js Thesaurus_Rights_DeleteTerm Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/DeleteTermAction.i18n.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/DeleteTermAction.i18n.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/DeleteTermAction.i18n.js (working copy) @@ -1,133 +0,0 @@ -/* - * Copyright 2013 Anyware Services - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Singleton class to delete contents - * @private - */ -Ext.define('Ametys.plugins.thesaurus.DeleteTermAction', { - singleton: true, - - /** - * Action function to be called by the controller. - * Will delete the contents registered by the controller. - * @param {Ametys.ribbon.element.ui.ButtonController} controller The controller calling this function - */ - act: function (controller) - { - var contentTargets = controller.getMatchingTargets(); - - if (contentTargets.length > 0) - { - Ametys.Msg.confirm("", - "", - Ext.bind(this._deleteConfirm, this, [controller, contentTargets], 1), - this - ); - } - }, - - /** - * Callback function invoked after the #act confirm box is closed - * @param {String} answer Id of the button that was clicked - * @param {Ametys.ribbon.element.ui.ButtonController} controller The controller calling the #act function - * @param {Ametys.message.MessageTarget[]} contentTargets The registered content targets - * @private - */ - _deleteConfirm: function (answer, controller, contentTargets) - { - if (answer == 'yes') - { - var contentIds = []; - for (var i=0; i < contentTargets.length; i++) - { - contentIds.push(contentTargets[i].getParameters().id); - } - - controller.serverCall ('deleteContents', [contentIds], this._deleteCb, { arguments: contentTargets }); - } - }, - - /** - * Callback function called after #act is processed. - * Fires Ametys.message.Message#DELETED message for deleted contents - * @param params The JSON result - * @param {Ametys.message.MessageTarget[]} targets The registered content targets - * @private - */ - _deleteCb: function (params, targets) - { - var deletedContents = params['deleted-contents']; - if (deletedContents.length > 0) - { - var deletedContentTargets = []; - for (var j=0; j < targets.length; j++) - { - for (var i=0; i < deletedContents.length; i++) - { - if (targets[j].getParameters().id == deletedContents[i].id) - { - deletedContentTargets.push(targets[j]); - } - } - } - - // Fires deleted event - Ext.create("Ametys.message.Message", { - type: Ametys.message.Message.DELETED, - targets: deletedContentTargets - }); - } - - var undeletedContents = params['undeleted-contents']; - var referencedContents = params['referenced-contents']; - if (undeletedContents.length > 0 || referencedContents.length > 0) - { - var message = ''; - - if (undeletedContents.length > 0) - { - message += ""; - for (var i=0; i < undeletedContents.length; i++) - { - message += (i > 0 ? ', ' : '') + undeletedContents[i].title; - } - } - - if (referencedContents.length > 0) - { - if (message.length > 0) - { - message += '

'; - } - - message += ""; - for (var i=0; i < referencedContents.length; i++) - { - message += (i > 0 ? ', ' : '') + referencedContents[i].title; - } - message += ".
"; - } - - Ametys.Msg.show({ - title: "", - msg: message, - buttons: Ext.Msg.OK, - icon: Ext.MessageBox.ERROR - }); - } - } -}); Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/ThesaurusActions.i18n.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/ThesaurusActions.i18n.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/ThesaurusActions.i18n.js (working copy) @@ -1,558 +0,0 @@ -/* - * Copyright 2013 Anyware Services - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * CRUD actions on thesaurus - * @private - */ -Ext.define('Ametys.plugins.thesaurus.ThesaurusActions', { - singleton: true, - - /** - * Open a thesaurus tool - */ - openThesaurus: function (controller) - { - Ametys.tool.ToolsManager.openTool(controller.getInitialConfig('opentool-role'), {'id': controller.getInitialConfig('thesaurusId')}); - }, - - /** - * This action creates a new thesaurus - * @param {Ametys.ribbon.element.ui.ButtonController} controller The controller calling this function - */ - createThesaurus: function(controller) - { - Ametys.plugins.thesaurus.helper.EditLabelDialogBox.open (Ametys.getPluginResourcesPrefix('thesaurus') + "/img/actions/add_thesaurus_16.png", - "", - "", - Ext.bind (this._doCreateThesaurus, this), - ""); - }, - - /** - * Creates a new thesaurus - * @param {String} title The title - * @private - */ - _doCreateThesaurus: function (title) - { - Ametys.data.ServerComm.callMethod({ - role: "org.ametys.plugins.thesaurus.ThesaurusDAO", - methodName: 'createThesaurus', - parameters: [title], - errorMessage: "", - callback: { - handler: this._createThesaurusCb, - scope: this - } - }); - }, - - /** - * @private - * Callback function after creating thesaurus - * @param {Object} result The result object - * @param {Object[]} args The callback arguments - */ - _createThesaurusCb: function (result, args) - { - Ext.create("Ametys.message.Message", { - type: Ametys.message.Message.CREATED, - targets: { - type: Ametys.message.MessageTarget.THESAURUS, - parameters: { - id: result.id, - label: result.label - } - } - }); - - // Open thesaurus tool - Ametys.tool.ToolsManager.openTool('uitool-thesaurus', { - id: result.id - }); - }, - - /** - * This action renames a thesaurus - * @param {Ametys.ribbon.element.ui.ButtonController} controller The controller calling this function - */ - renameThesaurus: function(controller) - { - var target = controller.getMatchingTargets()[0]; - if (target != null) - { - Ametys.plugins.thesaurus.helper.EditLabelDialogBox.open (Ametys.getPluginResourcesPrefix('thesaurus') + "/img/actions/rename_thesaurus_16.png", - "", - null, - Ext.bind (this._doRenameThesaurus, this, [target.getParameters().id], true), - target.getParameters().label); - } - }, - - /** - * Creates a new thesaurus - * @param {String} title The title - * @param {String} thesaurusId The id of thesaurus - * @private - */ - _doRenameThesaurus: function (title, thesaurusId) - { - Ametys.data.ServerComm.callMethod({ - role: "org.ametys.plugins.thesaurus.ThesaurusDAO", - methodName: 'updateThesaurus', - parameters: [title, thesaurusId], - errorMessage: "", - callback: { - handler: this._renameThesaurusCb, - scope: this - } - }); - }, - - /** - * @private - * Callback function after renaming thesaurus - * @param {Object} result The result object - * @param {Object[]} args The callback arguments - */ - _renameThesaurusCb: function (result, args) - { - Ext.create("Ametys.message.Message", { - type: Ametys.message.Message.MODIFIED, - targets: { - type: Ametys.message.MessageTarget.THESAURUS, - parameters: { - id: result.id, - label: result.label - } - } - }); - }, - - /** - * This action delete a thesaurus - * @param {Ametys.ribbon.element.ui.ButtonController} controller The controller calling this function - */ - deleteThesaurus: function(controller) - { - var target = controller.getMatchingTargets()[0]; - if (target != null) - { - var confirmMsg = "" + "" + target.getParameters().label + " ?" + ""; - Ametys.Msg.confirm("", - confirmMsg, - function(btn) { - if (btn == 'yes') - { - Ametys.data.ServerComm.callMethod({ - role: "org.ametys.plugins.thesaurus.ThesaurusDAO", - methodName: 'deleteThesaurus', - parameters: [target.getParameters().id], - waitMessage: "", - errorMessage: "", - callback: { - handler: this._deleteThesaurusCb, - scope: this - } - }); - } - - }, this - ); - } - }, - - /** - * @private - * Callback function after deleting thesaurus - * @param {Object} result The result object - * @param {Object[]} args The callback arguments - */ - _deleteThesaurusCb: function (result, args) - { - if (result['has-references']) - { - Ametys.Msg.show({ - title: "", - msg: "", - buttons: Ext.Msg.OK, - icon: Ext.Msg.ERROR - }); - return; - } - - Ext.create("Ametys.message.Message", { - type: Ametys.message.Message.DELETED, - targets: { - type: Ametys.message.MessageTarget.THESAURUS, - parameters: { - id: result.id - } - } - }); - - Ametys.Msg.alert( - "", - "" - ); - }, - - /** - * This action creates a new microthesaurus - * @param {Ametys.ribbon.element.ui.ButtonController} controller The controller calling this function - */ - createMicrothesaurus: function(controller) - { - var tool = Ametys.tool.ToolsManager.getFocusedTool(); - var thesaurusId = tool.getThesaurusId(); - - Ametys.plugins.thesaurus.helper.EditLabelDialogBox.open (Ametys.getPluginResourcesPrefix('thesaurus') + "/img/actions/add_mt_16.png", - "", - null, - Ext.bind (this._doCreateMicrothesaurus, this, [thesaurusId], true), - ""); - }, - - /** - * Creates a new microthesaurus - * @param {String} title The title - * @param {String} thesaurusId The id of thesaurus - * @private - */ - _doCreateMicrothesaurus: function (title, thesaurusId) - { - Ametys.data.ServerComm.callMethod({ - role: "org.ametys.plugins.thesaurus.ThesaurusDAO", - methodName: 'createMicrothesaurus', - parameters: [title, thesaurusId], - errorMessage: "", - callback: { - handler: this._createMicrothesaurusCb, - scope: this - } - }); - }, - - /** - * @private - * Callback function after creating new microthesaurus - * @param {Object} result The result object - * @param {Object[]} args The callback arguments - */ - _createMicrothesaurusCb: function (result, args) - { - Ext.create("Ametys.message.Message", { - type: Ametys.message.Message.CREATED, - targets: { - type: Ametys.message.MessageTarget.MICROTHESAURUS, - parameters: { - id: result.id, - thesaurusId: result.thesaurusId - } - } - }); - }, - - /** - * This action edits a microthesaurus - * @param {Ametys.ribbon.element.ui.ButtonController} controller The controller calling this function - */ - editMicrothesaurus: function(controller) - { - var target = controller.getMatchingTargets()[0]; - if (target != null) - { - var mtTarget = target.getSubtarget(Ametys.message.MessageTarget.MICROTHESAURUS); - - if (mtTarget != null) - { - Ametys.plugins.thesaurus.helper.EditLabelDialogBox.open (Ametys.getPluginResourcesPrefix('thesaurus') + "/img/actions/rename_mt_16.png", - "", - null, - Ext.bind (this._doRenameMicrothesaurus, this, [mtTarget.getParameters().id], true), - mtTarget.getParameters().label); - } - } - }, - - /** - * Renames a microthesaurus - * @param {String} title The new title - * @param {String} microthesaurusId The id of microthesaurus - * @private - */ - _doRenameMicrothesaurus: function (title, microthesaurusId) - { - Ametys.data.ServerComm.callMethod({ - role: "org.ametys.plugins.thesaurus.ThesaurusDAO", - methodName: 'updateMicrothesaurus', - parameters: [title, microthesaurusId], - errorMessage: "", - callback: { - handler: this._updateMicrothesaurusCb, - scope: this - } - }); - }, - - /** - * @private - * Callback function after creating new microthesaurus - * @param {Object} result The result object - * @param {Object[]} args The callback arguments - */ - _updateMicrothesaurusCb: function (result, args) - { - Ext.create("Ametys.message.Message", { - type: Ametys.message.Message.MODIFIED, - targets: { - type: Ametys.message.MessageTarget.MICROTHESAURUS, - parameters: { - id: result.id, - thesaurusId: result.thesaurusId - } - } - }); - }, - - /** - * This action deletes a microthesaurus - * @param {Ametys.ribbon.element.ui.ButtonController} controller The controller calling this function - */ - deleteMicrothesaurus: function(controller) - { - var target = controller.getMatchingTargets()[0]; - if (target != null) - { - var mtTarget = target.getSubtarget(Ametys.message.MessageTarget.MICROTHESAURUS); - - if (mtTarget != null) - { - var confirmMsg = "" + "" + mtTarget.getParameters().label + " ?"; - Ametys.Msg.confirm("", - confirmMsg, - function(btn) { - if (btn == 'yes') - { - Ametys.data.ServerComm.callMethod({ - role: "org.ametys.plugins.thesaurus.ThesaurusDAO", - methodName: 'deleteMicrothesaurus', - parameters: [mtTarget.getParameters().id], - waitMessage: "", - errorMessage: "", - callback: { - handler: this._deleteMicrothesaurusCb, - scope: this - } - }); - } - - }, this - ); - } - } - }, - - /** - * @private - * Callback function after deleting microthesaurus - * @param {Object} result The result object - * @param {Object[]} args The callback arguments - */ - _deleteMicrothesaurusCb: function (result, args) - { - if (result['has-references']) - { - Ametys.Msg.show({ - title: "", - msg: "", - buttons: Ext.Msg.OK, - icon: Ext.Msg.ERROR - }); - return; - } - - Ext.create("Ametys.message.Message", { - type: Ametys.message.Message.DELETED, - targets: { - type: Ametys.message.MessageTarget.MICROTHESAURUS, - parameters: { - id: result.id, - thesaurusId: result.thesaurusId - } - } - }); - - Ametys.Msg.alert( - "", - "" - ); - }, - - /** - * Create a new term in microthesaurus - * @param {Ametys.ribbon.element.ui.ButtonController} controller The controller calling this function - */ - createTerm: function (controller) - { - var message = Ametys.message.MessageBus.getCurrentSelectionMessage(); - var target = message.getTarget(Ametys.message.MessageTarget.THESAURUS); - if (target != null) - { - var mtTarget = target.getSubtarget(Ametys.message.MessageTarget.MICROTHESAURUS); - - if (mtTarget != null) - { - var parentId = mtTarget.getParameters().id; - - var termTarget = mtTarget.getSubtarget(Ametys.message.MessageTarget.CONTENT); - if (termTarget != null) - { - parentId = termTarget.getParameters().id; - } - - Ametys.plugins.thesaurus.helper.EditLabelDialogBox.open (Ametys.getPluginResourcesPrefix('thesaurus') + "/img/actions/add_term_16.png", - "", - null, - Ext.bind (this._doCreateTerm, this, [parentId], true)); - - } - } - }, - - /** - * Create a new term - * @param {String} title The term's title - * @param {String} parentId The parent id - * @private - */ - _doCreateTerm: function (title, parentId) - { - Ametys.data.ServerComm.callMethod({ - role: "org.ametys.plugins.thesaurus.ThesaurusDAO", - methodName: 'createTerm', - parameters: [title, 'fr', parentId], // FIXME fr hard coded - errorMessage: "", - callback: { - handler: this._createTermCb, - scope: this - } - }); - }, - - /** - * @private - * Callback function after creating or updating term - * @param {Object} result The result object - * @param {Object[]} args The callback arguments - */ - _createTermCb: function (result, args) - { - Ext.create("Ametys.message.Message", { - type: Ametys.message.Message.CREATED, - targets: { - type: Ametys.message.MessageTarget.CONTENT, - parameters: { - ids: [result.id] - } - } - }); - }, - - /** - * This action opens a term - * @param {Ametys.ribbon.element.ui.ButtonController} controller The controller calling this function - */ - openTerm: function(controller) - { - var target = controller.getMatchingTargets()[0]; - if (target != null) - { - var mtTarget = target.getSubtarget(Ametys.message.MessageTarget.MICROTHESAURUS); - - if (mtTarget != null) - { - var termTarget = mtTarget.getSubtarget(Ametys.message.MessageTarget.CONTENT); - if (termTarget != null) - { - Ametys.tool.ToolsManager.openTool('uitool-content', {'id': termTarget.getParameters().id}); - } - } - } - }, - - /** - * This action opens a term - * @param {Ametys.ribbon.element.ui.ButtonController} controller The controller calling this function - */ - editTerm: function(controller) - { - var target = controller.getMatchingTargets()[0]; - if (target != null) - { - if (target.getType() == Ametys.message.MessageTarget.CONTENT) - { - Ametys.tool.ToolsManager.openTool('uitool-content', {'id': target.getParameters().id, mode: 'edit'}); - } - else if (target.getType() == Ametys.message.MessageTarget.THESAURUS_CANDIDATE) - { - Ametys.plugins.thesaurus.helper.EditCandidateHelper.open (Ametys.getPluginResourcesPrefix('thesaurus') + '/img/actions/add_candidate_16.png', - "", Ext.bind(this._doEditCandidate, this, [target.getParameters().id], true), target.getParameters().title, target.getParameters().comment); - } - } - }, - - /** - * @private - * Do edit the candidate - * @param {String} label The label - * @param {String} comment The comment - * @param {String} id The id of candidate to edit - */ - _doEditCandidate: function (label, comment, id) - { - Ametys.data.ServerComm.callMethod({ - role: "org.ametys.plugins.thesaurus.ThesaurusDAO", - methodName: 'editCandidate', - parameters: [id, label, comment], - errorMessage: "", - callback: { - handler: this._editCandidateCb, - scope: this - } - }); - }, - - /** - * @private - * Callback function called after editing candidate - * @param {Object} result The server response - * @param {Object} args The callback arguments - */ - _editCandidateCb: function (result, args) - { - Ext.create("Ametys.message.Message", { - type: Ametys.message.Message.MODIFIED, - targets: { - type: Ametys.message.MessageTarget.THESAURUS_CANDIDATE, - parameters: { - ids: [result.id] - } - } - }); - } -}); Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/ThesaurusActions.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/ThesaurusActions.js (revision 30361) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/ThesaurusActions.js (working copy) @@ -428,8 +428,8 @@ Ametys.plugins.thesaurus.helper.EditLabelDialogBox.open (Ametys.getPluginResourcesPrefix('thesaurus') + "/img/actions/add_term_16.png", "", null, - Ext.bind (this._doCreateTerm, this, [parentId], true)); - + Ext.bind (this._doCreateTerm, this, [parentId], true), + ""); } } }, Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/controller/ThesaurusGalleryController.i18n.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/controller/ThesaurusGalleryController.i18n.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/controller/ThesaurusGalleryController.i18n.js (working copy) @@ -1,134 +0,0 @@ -/* - * Copyright 2013 Anyware Services - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * This class controls a ribbon gallery for thesaurus. - * @private - */ -Ext.define('Ametys.plugins.thesaurus.controller.ThesaurusGalleryController', { - extend: 'Ametys.ribbon.element.ui.ButtonController', - - /** - * @inheritdoc - * Add a listener on 'menushow' event - */ - createUI: function () - { - var elt = this.callParent(arguments); - elt.on ('menushow', this._onMenuShow, this); - return elt; - }, - - /** - * Listener on 'menushow' event
- * @param {Ext.button.Button} btn The button - * @param {Ext.menu.Menu} menu The menu - * @private - */ - _onMenuShow: function (btn, menu) - { - this.serverCall ('getGalleryItems', [], Ext.bind(this._getGalleryItemsCb, this), { arguments: [] }); - }, - - /** - * Callback function called after retrieving gallery's items - * Reloads the gallery. - * @param {Object} result The server response. - * @param {Object[]} args The callback arguments - */ - _getGalleryItemsCb: function (result, args) - { - var me = this; - this.getUIControls().each(function (element) { - - if (element.menu) - { - var menuGallery = element.menu.items.get(0); - - // Remove old items - menuGallery.removeAll(); - - var gpItems = []; - - var items = result['gallery-items']; - for (var i=0; i < items.length; i++) - { - var itemConfig = items[i]; - itemConfig.pluginName = me.getPluginName(); - - var element = Ext.create("Ametys.ui.fluent.ribbon.controls.gallery.MenuGalleryButton", Ext.apply({ - text: itemConfig.label, - tooltip: { - title: itemConfig.label, - image: Ametys.CONTEXT_PATH + itemConfig['icon-large'], - imageWidth: 48, - imageHeight: 48, - text: itemConfig.description, - helpId: itemConfig.helpId, - inribbon: false - }, - icon: Ametys.CONTEXT_PATH + itemConfig['icon-medium'], - scale: 'large', - - disabled: false, - controlId: me.getId(), - thesaurusId: itemConfig.thesaurusId, - - handler: Ext.bind(me._onItemPress, me), - enableToggle: false, - pressed: false - }, me.getInitialConfig('items-config') || {})); - - gpItems.push(element); - } - - menuGallery.add({title: "", items: gpItems}); - } - }); - }, - - /** - * This function is called when an item of the gallery is pressed - * @param {Ametys.ui.fluent.ribbon.controls.gallery.MenuGalleryButton} button The pressed button - * @param {Boolean} state The button state. - * @private - */ - _onItemPress: function (button, state) - { - var actionFn = button.action; - if (actionFn) - { - var role = button['opentool-role']; - - var tool = Ametys.tool.ToolsManager.getTool(role + "$" + button.thesaurusId); - if (tool != null) - { - if (tool.isActivated()) - { - tool.close(); - } - else - { - tool.focus(); - } - } - else - { - Ametys.tool.ToolsManager.openTool(role, {'id': button.thesaurusId}); - } - } - } -}); \ No newline at end of file Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/controller/ThesaurusGalleryController.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/controller/ThesaurusGalleryController.js (revision 30361) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/controller/ThesaurusGalleryController.js (working copy) @@ -86,6 +86,7 @@ disabled: false, controlId: me.getId(), thesaurusId: itemConfig.thesaurusId, + thesaurusLabel: itemConfig.label, handler: Ext.bind(me._onItemPress, me), enableToggle: false, @@ -127,7 +128,7 @@ } else { - Ametys.tool.ToolsManager.openTool(role, {'id': button.thesaurusId}); + Ametys.tool.ToolsManager.openTool(role, {'id': button.thesaurusId, 'label': button.thesaurusLabel}); } } } Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/form/widget/ComposeTerm.i18n.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/form/widget/ComposeTerm.i18n.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/form/widget/ComposeTerm.i18n.js (working copy) @@ -1,33 +0,0 @@ -/* - * Copyright 2013 Anyware Services - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @private - * This class provides a widget to edit sub-contents.
- * Sub-contents can be added and removed, but the changes will only be effective when saving the parent content. - * - * This widget is the default widget registered for fields of type Ametys.cms.form.WidgetManager#TYPE_CONTENT.
- */ -Ext.define('Ametys.plugins.thesaurus.form.widget.ComposeTerm', { - - extend: 'Ametys.cms.form.widget.ComposeContent', - - includePrivate: true, - - createButtonIcon: Ametys.getPluginResourcesPrefix('thesaurus') + '/img/actions/add_term_16.png', - createButtonTooltip: "" - -}); Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/form/widget/ComposeTerm.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/form/widget/ComposeTerm.js (revision 30361) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/form/widget/ComposeTerm.js (working copy) @@ -22,8 +22,8 @@ * This widget is the default widget registered for fields of type Ametys.cms.form.WidgetManager#TYPE_CONTENT.
*/ Ext.define('Ametys.plugins.thesaurus.form.widget.ComposeTerm', { - - extend: 'Ametys.cms.form.widget.ComposeContent', + + extend: 'Ametys.cms.form.widget.ComposeContent', includePrivate: true, Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/form/widget/SelectTerm.i18n.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/form/widget/SelectTerm.i18n.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/form/widget/SelectTerm.i18n.js (working copy) @@ -1,485 +0,0 @@ -/* - * Copyright 2013 Anyware Services - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * This class provides a widget to select one or more terms.
- * This widget is registered for fields of type Ametys.cms.form.WidgetManager#TYPE_CONTENT.
- * @private - */ -Ext.define('Ametys.plugins.thesaurus.form.widget.SelectTerm', { - - extend: 'Ametys.cms.form.widget.SelectContent', - - allowSearch: true, - allowCreation: false, - openOnClick: true, - excludeSubContents: false, - includePrivate: true, - - searchButtonIcon: Ametys.getPluginResourcesPrefix('thesaurus') + '/img/thesaurus_16.png', - searchButtonTooltip: "", - - boxTitle: "", - boxIcon: Ametys.getPluginResourcesPrefix('thesaurus') + '/img/thesaurus_16.png', - - /** - * @cfg {Boolean} hideCandidates Set to 'true' to hide candidates - */ - /** - * @property {Boolean} _hideCandidates See {#cfg-hideCandidates} - */ - - /** - * @cfg {Boolean} [allowSeeIndexedContent=true] Set to `false` to hide the button to see indexed contents. - */ - allowSeeIndexedContent: true, - - /** - * @cfg {Boolean} [allowToggleAutoposting=false] Set to `true` to allow autoposting during search. - */ - allowToggleAutoposting: false, - /** - * @property {Boolean} _autoposting Is the autoposting enabled? See {#cfg-allowToggleAutoposting} - * @private - */ - - /** - * @cfg {String} thesaurusName The unique name of thesaurus - */ - /** - * @property {String} _thesaurusName See {#cfg-thesaurus} - * @private - */ - - /** - * @cfg {String} microthesaurusName The unique name of microthesaurus - */ - /** - * @property {String} _microthesaurusName See {#cfg-microthesaurusName} - * @private - */ - - /** - * @property {String} _microthesaurusId The id of microthesaurus - * @private - */ - - /** - * @property {String} _termId The id of current term - * @private - */ - - /** - * @cfg {String} showGenericTermAlert=true True to display a user alert when a generic term is selected - */ - showGenericTermAlert: true, - /** - * @cfg {String} genericTermTitle The title of alert when a generic term is selected - */ - genericTermAlertTitle: "", - /** - * @cfg {String} genericTermDesc The description of alert when a generic term is selected - */ - genericTermAlertDesc: "", - - statics: { - /** - * Open the content tool on the given content. - * @param {String} contentId The ID of the content to open. - */ - openTerm: function(contentId) - { - // Defer the call to let the focus happen before opening the tool. - Ext.defer(Ametys.tool.ToolsManager.openTool, 1, Ametys.tool.ToolsManager, ['uitool-content', {id: contentId}]); - } - }, - - constructor: function(config) - { - this.callParent(arguments); - - this._thesaurusName = config.thesaurusName || null; - this._microthesaurusName = config.microthesaurusName || null; - - if (this._thesaurusName == null && this._microthesaurusName == null) - { - var contentTarget = Ametys.message.MessageBus.getCurrentSelectionMessage().getTarget(Ametys.message.MessageTarget.CONTENT); - if (contentTarget != null && Ext.Array.contains (contentTarget.getParameters().types, 'org.ametys.plugins.thesaurus.Content.term')) - { - // A term is currently in edition, the search term should be in its own microthesaurus - this._microthesaurusId = contentTarget.getParameters().additionalData.microthesaurusId; - } - } - - this._hideCandidates = config.hideCandidates ? config.hideCandidates == 'true' : false; - - if (!this._microthesaurusId) - { - this._getMicrotheaurusId(Ext.bind(this._loadStore, this)); - } - }, - - /** - * Load the store - */ - _loadStore: function() - { - if (this._microthesaurusId) - { - this.combobox.getStore().load(); - } - }, - - initComponent: function() - { - this._autoposting = this.allowToggleAutoposting == true || this.allowToggleAutoposting == 'true'; - this.callParent(); - }, - - getComboBoxConfig: function () - { - var cbConfig = this.callParent(arguments); - - cbConfig.listeners = cbConfig.listeners || {}; - - // Adding a listener on 'change' event - cbConfig.listeners.change = {fn: this._onTermChange, scope: this}; - - return cbConfig; - }, - - /** - * @inheritdoc - */ - getItems: function() - { - var items = this.callParent(arguments); - - if (this.allowSeeIndexedContent == true || this.allowSeeIndexedContent == 'true') - { - items.push(Ext.create('Ext.button.Button', { - itemId: 'see-indexed-btn', - text: '', - icon: Ametys.getPluginResourcesPrefix('thesaurus') + '/img/widget/see_contents_16.png', - tooltip: "", - disabled: true, // start disable, a listener is responsible for the button status (enabled/disabled) - handler: this.seeIndexedContents, - scope: this - })); - } - - if (this.allowToggleAutoposting == true || this.allowToggleAutoposting == 'true') - { - items.push(Ext.create('Ext.button.Button', { - itemId: 'toggle-autoposting', - text: '', - icon: Ametys.getPluginResourcesPrefix('thesaurus') + (this._autoposting ? '/img/widget/autoposting_16.png' : '/img/widget/no-autoposting_16.png'), - tooltip: (this._autoposting ? "" : ""), - enableToggle: true, - pressed: this._autoposting, - toggleHandler: function (btn, state) { - this._autoposting = state; - - if (this._autoposting) - { - btn.setIcon(Ametys.getPluginResourcesPrefix('thesaurus') + '/img/widget/autoposting_16.png'); - btn.setTooltip("") - } - else - { - btn.setIcon(Ametys.getPluginResourcesPrefix('thesaurus') + '/img/widget/no-autoposting_16.png'); - btn.setTooltip(""); - } - }, - scope: this - })); - } - - return items; - }, - - /** - * Open a search tool with the indexed contents. - */ - seeIndexedContents: function () - { - var contentTarget = Ametys.message.MessageBus.getCurrentSelectionMessage().getTarget(Ametys.message.MessageTarget.CONTENT); - - var fieldName = this.getName(); - fieldName = Ext.String.startsWith (fieldName, 'content.input.') ? fieldName.substring('content.input.'.length) : fieldName; - - var indexFieldPath = []; - - var pathSegments = fieldName.split('.'); - for (var i=0; i < pathSegments.length; i++) - { - // Remove repeater entry from path - if (!/^[0-9]+$/.test(pathSegments[i])) - { - indexFieldPath.push(pathSegments[i]); - } - } - - var indexField = indexFieldPath.join('.'); - var searchFieldName = 'metadata-' + indexField + '-eq'; - - var value = this.getValue(); - value = Ext.isArray(value) ? value : [value]; - - if (value.length > 0) - { - var values = {}; - values[searchFieldName] = value; - - // Defer the call to let the focus happen before opening the tool. - Ext.defer(Ametys.tool.ToolsManager.openTool, 1, Ametys.tool.ToolsManager, ['uitool-search-indexed-contents', { - contentId: contentTarget.getParameters().id, - indexField: indexField, - indexValues: this.getValue(), - modelId: 'search-model.indexed-contents', - id: 'search-model.indexed-contents;' + value.join('-'), - values: values, - startSearchAtOpening: true - }]); - } - }, - - /** - * @inheritdoc - */ - getSubmitData: function() - { - if (this.allowToggleAutoposting == true || this.allowToggleAutoposting == 'true') - { - var data = {}; - data[this.name] = null; - var value = this.combobox.getValue(); - if (value != null && value !== '' && !(Ext.isArray(value) && value.length == 0)) - { - data[this.name] = {value: value, autoposting: this._autoposting}; - } - return data; - } - else - { - return this.callParent(arguments); - } - }, - - /** - * @inheritdoc - */ - selectContentsBySearch: function() - { - if (!this._microthesaurusId) - { - this._getMicrotheaurusId (this._openDialogBox); - } - else - { - this._openDialogBox(); - } - }, - - /** - * Open the thesaurus assistant - * @private - */ - _openDialogBox: function () - { - Ametys.plugins.thesaurus.helper.ChooseTermHelper.open ({ - icon: this.boxIcon, - title: this.boxTitle, - - callback: Ext.bind(this._selectTermsCb, this), - - showGenericTermAlert: this.showGenericTermAlert, - genericTermAlertTitle: this.genericTermAlertTitle, - genericTermAlertDesc: this.genericTermAlertDesc, - - multiple: this.multiple, - - microthesaurusId: this._microthesaurusId, - hideCandidates: this._hideCandidates, - values: this.getValue() - }); - }, - - /** - * Listener when the value change, to enable/disable the button to see indexed contents. - * @param {Ext.ux.form.field.BoxSelect} combobox The combobox - * @param {String|String[]} newValue The new value - * @param {String|String[]} oldValue The old value - */ - _onTermChange: function(combobox, newValue, oldValue) - { - var seeIndexedBtn = this.down('#see-indexed-btn'), enabled; - if (seeIndexedBtn) - { - hasValue = newValue != null && newValue !== '' && !(Ext.isArray(newValue) && newValue.length == 0); - seeIndexedBtn.setDisabled(!hasValue); - } - }, - - /** - * This function is called after selecting terms in the tree - * Sets the value of the field. - * @param {String|String[]} contentIds The identifiers of selected terms - * @private - */ - _selectTermsCb: function(contentIds) - { - this.setValue(contentIds); - }, - - setValue: function (value) - { - if (Ext.isObject(value) && value.value) - { - this.callParent([value.value]); - - if (this.allowToggleAutoposting == true || this.allowToggleAutoposting == 'true') - { - this.down('#toggle-autoposting').toggle(Ext.isBoolean(value.autoposting) ? value.autoposting : true); - } - } - else - { - this.callParent(arguments); - } - - }, - - getStore: function() - { - return Ext.create('Ext.data.Store', { - autoLoad: false, // load will be made once microthesaurusId has been found - - model: 'Ametys.plugins.thesaurus.form.widget.SelectTerm.ContentEntry', - proxy: { - type: 'ametys', - plugin: 'thesaurus', - url: 'select-term-search/list.xml', - reader: { - type: 'xml', - record: '> content', - root: 'contents' - } - }, - - pageSize: this.maxResult, - - remoteSort: true, - sortOnLoad: true, - sorters: [{property: 'title', direction:'ASC'}], - - listeners: { - beforeload: {fn: this._onStoreBeforeLoad, scope: this} - } - }); - }, - - /** - * @private - * Retrieve the microthesaurus' id by its name - * @param {Function} cb The function to called after retrieving. Can be null - */ - _getMicrotheaurusId: function (cb) - { - Ametys.data.ServerComm.callMethod({ - role: "org.ametys.plugins.thesaurus.ThesaurusDAO", - methodName: 'getMicrothesaurusIdByName', - parameters: [this._thesaurusName, this._microthesaurusName], - errorMessage: "" + this._microthesaurusName + ' / ' + this._thesaurusName, - callback: { - handler: function (result, args) { - if (result.microthesaurusId) - { - this._microthesaurusId = result.microthesaurusId; - if (Ext.isFunction(cb)) - { - cb(); - } - } - else - { - this.getLogger().error("" + this._thesaurusName + '/' + this._microthesaurusName); - this.disable(); - } - }, - scope: this - } - }); - }, - - /** - * Set the request parameters before loading the store. - * @param {Ext.data.Store} store The store. - * @param {Ext.data.Operation} operation The Ext.data.Operation object that will be passed to the Proxy to load the Store. - */ - _onStoreBeforeLoad: function(store, operation) - { - if (!this._microthesaurusId) - { - return false; - } - - var id; - if (!operation.params) // can happens in case of a cancelled load - { - id = Ext.Array.from(this.getValue()); - operation.params = {}; - } - else - { - id = operation.params.id ? operation.params.id.split(',') : null; - } - - var me = this; - Ext.apply(operation.params, { - 'id': id, - 'excludeSubContents': this.excludeSubContents, - 'title': operation.params.query, - 'contentType': me.contentType, - 'microthesaurusId': me._microthesaurusId, - 'termId': me._termId - }); - }, - - /** - * @private - * Event when the combobox itemlist is clicked to open the term if required - * @param {Event} evt The click event - * @param {Ext.Element} el The item list - * @param {Object} o Options. Emtpy. - */ - _onComboboxItemListClick: function(evt, el, o) - { - // Handle clickable entry, in order to open the corresponding content. - var itemEl = evt.getTarget('.x-boxselect-item'), - spanEl = itemEl ? evt.getTarget('span.clickable') : false, - record; - - if (spanEl) - { - record = this.combobox.getRecordByListItemNode(itemEl); - if (record) - { - Ametys.plugins.thesaurus.form.widget.SelectTerm.openTerm(record.getId()); - } - } - } -}); Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/form/widget/SelectTerm.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/form/widget/SelectTerm.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/form/widget/SelectTerm.js (working copy) @@ -376,7 +376,7 @@ reader: { type: 'xml', record: '> content', - root: 'contents' + rootProperty: 'contents' } }, @@ -428,7 +428,7 @@ /** * Set the request parameters before loading the store. * @param {Ext.data.Store} store The store. - * @param {Ext.data.Operation} operation The Ext.data.Operation object that will be passed to the Proxy to load the Store. + * @param {Ext.data.operation.Operation} operation The Ext.data.Operation object that will be passed to the Proxy to load the Store. */ _onStoreBeforeLoad: function(store, operation) { @@ -438,25 +438,25 @@ } var id; - if (!operation.params) // can happens in case of a cancelled load + if (!operation.getParams()) // can happens in case of a cancelled load { id = Ext.Array.from(this.getValue()); - operation.params = {}; + operation.setParams({}); } else { - id = operation.params.id ? operation.params.id.split(',') : null; + id = operation.getParams().id ? operation.getParams().id.split(',') : null; } var me = this; - Ext.apply(operation.params, { + operation.setParams( Ext.apply(operation.getParams(), { 'id': id, 'excludeSubContents': this.excludeSubContents, - 'title': operation.params.query, + 'title': operation.getParams().query, 'contentType': me.contentType, 'microthesaurusId': me._microthesaurusId, 'termId': me._termId - }); + })); }, /** Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/form/widget/SelectTerm/ContentEntry.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/form/widget/SelectTerm/ContentEntry.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/form/widget/SelectTerm/ContentEntry.js (working copy) @@ -36,8 +36,8 @@ { name: 'clickable', type: 'boolean', - convert: function (v, record) { - return record.get('type') == 'org.ametys.plugins.thesaurus.Content.term' ? true : false; + calculate: function (data) { + return data.type == 'org.ametys.plugins.thesaurus.Content.term' ? true : false; } } ] Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/helper/ChooseTermHelper.i18n.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/helper/ChooseTermHelper.i18n.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/helper/ChooseTermHelper.i18n.js (working copy) @@ -1,395 +0,0 @@ -/* - * Copyright 2014 Anyware Services - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Dialog box used to select one or more terms - * @private - */ -Ext.define('Ametys.plugins.thesaurus.helper.ChooseTermHelper', { - singleton: true, - - /** - * @cfg {String} thesaurusId (required) The id of thesaurus - */ - - /** - * @cfg {String} microthesaurusId (required) The id of microthesaurus - */ - - /** - * @cfg {String} hideCandidates=false Set to 'true' to hide candidates - */ - - /** - * @cfg {Boolean} multiple=false True to allow multiple selections. Defaults to false. - */ - - /** - * @cfg {String} showGenericTermAlert=true True to display a user alert when a generic term is selected - */ - showGenericTermAlert: true, - /** - * @cfg {String} genericTermTitle The title of alert when a generic term is selected - */ - genericTermAlertTitle: "", - /** - * @cfg {String} genericTermDesc The description of alert when a generic term is selected - */ - genericTermAlertDesc: "", - - /** - * @property {Boolean} _hideCandidates=false See {#cfg-hideCandidates} - * @private - */ - - /** - * @property {String} _microthesaurusId See {#cfg-microthesaurusId} - * @private - */ - - /** - * @property {String} _thesaurusId See #cfg-thesaurusId - * @private - */ - - /** - * @property {Function} _cbFn The call back function to call after choosing contents - * @private - */ - - /** - * @property _box {Ametys.window.DialogBox} The dialog box - * @private - */ - - /** - * @property _tree {Ametys.plugins.thesaurus.tool.ThesaurusTreePanel} The thesaurus tree panel - * @private - */ - - /** - * Configure and open the dialog box - * @param {Object} config The configuration options : - * @param {String} config.icon The full path to icon (16x16 pixels) for the dialog box - * @param {String} config.title The title of the dialog box. - * @param {String} config.thesaurusId The id of thesaurus - * @param {String} config.microthesaurusId The id of microthesaurus - * @param {String} [config.values] the selected terms - * @param {Boolean} [config.hideCandidates=false] `true` to hide candidates - * @param {Boolean} [config.multiple=false] `true` to allow selecting multiple contents, `false` otherwise. - * @param {Function} config.callback The callback function invoked when terms are selected. The callback function will received the following parameters: - * @param {String[]} config.callback.terms The selected terms as a Array of ids - */ - open: function (config) - { - config = config || {}; - - this.multiple = config.multiple || false; - this._cbFn = config.callback; - - this._thesaurusId = config.thesaurusId; - this._microthesaurusId = config.microthesaurusId; - this._hideCandidates = config.hideCandidates || false; - - this.showGenericTermAlert = config.showGenericTermAlert || this.showGenericTermAlert; - this.genericTermAlertTitle = config.genericTermAlertTitle || this.genericTermAlertTitle; - this.genericTermAlertDesc = config.genericTermAlertDesc || this.genericTermAlertDesc; - - this._createDialogBox(config.icon, config.title); - this._box.show(); - - this._tree.loadMicrothesaurii (null, Ext.bind(this._selectValues, this, [config.values || []], true)); - }, - - /** - * Select contents in tree - * @param {String[]} values the ids of contents to select - * @private - */ - _selectValues: function (values) - { - Ametys.data.ServerComm.callMethod({ - role: "org.ametys.plugins.thesaurus.ThesaurusDAO", - methodName: 'getTermsPaths', - parameters: [Ext.Array.from(values)], - errorMessage: "", - callback: { - handler: this._getTermsPathsCb, - scope: this - } - }); - }, - - /** - * Callback function called after retrieving the term paths. - * Expand nodes and checked them. - * @param {Object} result The JSON server response - * @param {Object} args The callback arguments - */ - _getTermsPathsCb: function (result, args) - { - var me = this; - me._tree.expandNodesByPath(result.paths, null, function (success, lastNode) { - if (success) - { - if (me.multiple) - { - lastNode.set('checked', true); - } - else - { - me._tree.getSelectionModel().select(lastNode); - } - } - }); - }, - - /** - * Creates the dialog box if it is not already created - * @param {String} icon The full path to icon (16x16 pixels) for the dialog box - * @param {String} title The title of the dialog box. - * @private - */ - _createDialogBox: function (icon, title) - { - this._tree = new Ametys.plugins.thesaurus.tool.ThesaurusTreePanel ({ - region: 'west', - split: true, - width: 300, - minWidth: 200, - maxWidth: 400, - - thesaurusId: this._thesaurusId, - microthesaurusId: this._microthesaurusId, - hideCandidates: this._hideCandidates, - - checkMode: this.multiple - }); - - this._tree.on('itemclick', this._onItemClick, this); - - this._box = Ext.create('Ametys.window.DialogBox', { - title: title, - icon: icon, - layout: 'border', - width: 800, - height: 500, - bodyPadding: '0', - - items: [this._tree, - { - xtype: 'panel', - region: 'center', - autoScroll: true - } - ], - - closeAction: 'destroy', - buttons : [{ - text :"", - handler : Ext.bind(this._validate, this) - }, { - text :"", - handler: Ext.bind(function() {this._box.close();}, this) - } - ] - }); - - }, - - /** - * This listener is called on the click event on an node is processed. - * Open the term. - * @param {Ext.view.View} view The view - * @param {Ext.data.Model} record The record that belongs to the item - * @param {HTMLElement} item The item's element - * @param {Number} index The item's index - * @private - */ - _onItemClick: function (view, record, item, index) - { - if (record.data.type == 'term') - { - Ametys.data.ServerComm.callMethod({ - role: "org.ametys.plugins.thesaurus.ThesaurusDAO", - methodName: 'getTermInformation', - parameters: [record.getId()], - errorMessage: "", - callback: { - handler: this._getTermInformationCb, - scope: this - } - }); - } - else - { - this._box.items.get(2).body.update (""); - } - - }, - - /** - * Callback function after getting information on a term - * @param {Object} result The result object - * @param {Object[]} args The callback arguments - * @private - */ - _getTermInformationCb: function(result, args) - { - var html = this._termTemplate.applyTemplate (result); - this._box.items.get(2).body.update (html); - }, - - /** - * Function called when clicking on 'Ok' button. - * Calls the callback function passed in {@link #method-open} and hide the dialog box. - * @private - */ - _validate: function() - { - var selectedNodes = this.multiple ? this._tree.getChecked() : this._tree.getSelectionModel().getSelection(); - - var hasAtLeastOneSelectedTerm = false; - var hasAtLeastOneGenericTerm = false; - - var termIds = []; - Ext.Array.each (selectedNodes, function (node) { - termIds.push(node.getId()); - - if (node.get('type') == 'term') - { - hasAtLeastOneSelectedTerm = true; - - // Is it possible to be more specific on first level nodes? - if (node.getDepth() == 1 - && (node.hasChildNodes() || !node.isLeaf()) - && node.findChildBy(function(child) { - return child.get('checked') == true; - }, this, true) == null) - { - hasAtLeastOneGenericTerm = true; - } - } - }, this); - - if (termIds.length > 0 && !hasAtLeastOneSelectedTerm) - { - Ametys.Msg.alert("", ""); - return; - } - - if (this.showGenericTermAlert && hasAtLeastOneGenericTerm) - { - Ametys.Msg.confirm( - this.genericTermAlertTitle, - this.genericTermAlertDesc, - function (buttonId) - { - if (buttonId != 'yes') - { - if (Ext.isFunction (this._cbFn)) - { - this._cbFn(this.multiple ? termIds : termIds[0]); - } - - this._box.close(); - } - }, - this - ); - } - else - { - if (Ext.isFunction (this._cbFn)) - { - this._cbFn(this.multiple ? termIds : termIds[0]); - } - - this._box.close(); - } - }, - - /** - * @private - * Select a node in the tree by its path - * @param {String} path the node path. - */ - _selectNodeByPath: function (path) - { - this._tree.selectNodesByPath ([path]); - }, - - /** - * @property {Ext.XTemplate} Template for term informations - * @private - */ - _termTemplate: Ext.create ('Ext.XTemplate', - "
", - "

{title}

", - "
", - "
", - "
{thesaurus}
", - "
", - "
", - "
", - "
{microthesaurus}
", - "
", - "", - "
", - "
", - "
", - "", - "{title}, ", - "", - "
", - "
", - "
", - "
", - "
", - "", - "{title}, ", - "", - "
", - "
", - "
", - "
", - "
{synonyms}
", - "
", - "
", - "
", - "
{applicationNote}
", - "
", - "
", - "
", - "
{explanatoryNote}
", - "
", - "
", - "", - "
", - "
", - "
{comment:this.convertToHtml}
", - "
", - "
", - "
", - { - convertToHtml: function(value) - { - return value.replace(/\n/g, '
'); - } - } - ) - -}); \ No newline at end of file Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/helper/EditCandidateHelper.i18n.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/helper/EditCandidateHelper.i18n.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/helper/EditCandidateHelper.i18n.js (working copy) @@ -1,158 +0,0 @@ -/* - * Copyright 2014 Anyware Services - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Dialog box used to select one or more terms - * @private - */ -Ext.define('Ametys.plugins.thesaurus.helper.EditCandidateHelper', { -singleton: true, - - /** - * @property {Boolean} _initialized True if the dialog box was already initialized - * @private - */ - _initialized: false, - - /** - * @property {Ametys.window.DialogBox} _box The dialog box - * @private - */ - - /** - * Open the dialog box - * @param {String} icon The full path to icon (16x16 pixels) for the dialog box - * @param {String} title The title of the dialog box. - * @param {Function} callback The callback function to called after validating dialog box - * @param {String} [label] The default value of title field - * @param {String} [comment] The default value of comment field - */ - open: function (icon, title, callback, label, comment) - { - this._cbFn = callback || Ext.emptyFn; - if (!this._delayedInitialize(icon, title)) - { - return false; - } - - this._box.show(); - - var form = this._form.getForm(); - form.findField('label').setValue(label || ''); - form.findField('comment').setValue(comment || ''); - form.findField('label').clearInvalid(); - form.findField('label').focus(true, 10); - }, - - /** - * Creates the dialog box if it is not already created - * @param {String} icon The full path to icon (16x16 pixels) for the dialog box - * @param {String} title The title of the dialog box. - * @private - */ - _delayedInitialize: function (icon, title) - { - if (!this._initialized) - { - this._form = new Ext.FormPanel({ - border :false, - bodyStyle :'padding:10px 10px 0', - - defaults: { - cls: 'ametys', - labelWidth: 100, - labelAlign: 'right', - labelSeparator: '', - msgTarget: 'side' - }, - - items:[{ - xtype: 'textfield', - fieldLabel :"", - ametysDescription :"", - name: 'label', - width: 380, - allowBlank: false - }, - { - xtype: 'textarea', - fieldLabel :"", - ametysDescription :"", - name :'comment', - width: 380, - height: 50 - } - ] - }); - - this._box = Ext.create('Ametys.window.DialogBox', { - - title: title, - icon: icon, - - layout :'fit', - width: 430, - height: 190, - - items : [ this._form ], - - closeAction: 'hide', - buttons : [ { - text :"", - handler : Ext.bind(this._ok, this) - }, { - text :"", - handler: Ext.bind(function() {this._box.close();}, this) - } - ] - }); - - this._initialized = true; - } - else - { - this._box.setTitle (title); - this._box.setIcon(icon); - } - - return true; - }, - - /** - * Function called when clicking on 'Ok' button. - * Calls the callback function passed in {@link #method-open} and hide the dialog box. - * @private - */ - _ok: function() - { - var form = this._form.getForm(); - if (!form.isValid()) - { - return; - } - - var label = form.findField('label').getValue(); - var comment = form.findField('comment').getValue(); - - if (Ext.isFunction (this._cbFn)) - { - this._cbFn (label, comment); - } - - this._box.hide(); - } - -}); \ No newline at end of file Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/helper/EditLabelDialogBox.i18n.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/helper/EditLabelDialogBox.i18n.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/helper/EditLabelDialogBox.i18n.js (working copy) @@ -1,144 +0,0 @@ -/* - * Copyright 2014 Anyware Services - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Dialog box used to create or edit a label - * @private - */ -Ext.define('Ametys.plugins.thesaurus.helper.EditLabelDialogBox', { - singleton: true, - - /** - * @property {Boolean} _initialized True if the dialog box was already initialized - * @private - */ - _initialized: false, - - /** - * @property {Ametys.window.DialogBox} _box The dialog box - * @private - */ - - /** - * Open the dialog box - * @param {String} icon The full path to icon (16x16 pixels) for the dialog box - * @param {String} title The title of the dialog box. - * @param {String} helpmessage The message displayed at the top of the dialog box. Can be null - * @param {Function} callback The callback function to called after validating dialog box - * @param {String} [value] The default value of title field - */ - open: function (icon, title, helpmessage, callback, value) - { - this._cbFn = callback || Ext.emptyFn; - this._delayedInitialize(icon, title, helpmessage); - - this._box.show(); - - var form = this._form.getForm(); - form.findField('title').setValue(value || ''); - form.findField('title').clearInvalid(); - form.findField('title').focus(true, 10); - }, - - /** - * Creates the dialog box if it is not already created - * @param {String} icon The full path to icon (16x16 pixels) for the dialog box - * @param {String} title The title of the dialog box. - * @param {String} helpmessage The message displayed at the top of the dialog box. Can be null - * @private - */ - _delayedInitialize: function (icon, title, helpmessage) - { - if (!this._initialized) - { - this._form = new Ext.FormPanel({ - border :false, - defaults: { - cls: 'ametys', - labelWidth: 100, - labelAlign: 'right', - labelSeparator: '', - msgTarget: 'side' - }, - - items:[{ - xtype: 'textfield', - fieldLabel :"", - name: 'title', - width: 380, - allowBlank: false - } - ] - }); - - this._box = Ext.create('Ametys.window.DialogBox', { - - title: title, - icon: icon, - - width: 430, - - items : [{ - xtype: 'component', - cls: 'text', - html: helpmessage || '' - }, this._form ], - - closeAction: 'hide', - buttons : [ { - text :"", - handler : Ext.bind(this._ok, this) - }, { - text :"", - handler: Ext.bind(function() {this._box.close();}, this) - } - ] - }); - - this._initialized = true; - } - else - { - this._box.setTitle (title); - this._box.setIcon(icon); - this._box.items.getAt(0).update(helpmessage || ''); - } - }, - - /** - * Function called when clicking on 'Ok' button. - * Calls the callback function passed in {@link #method-open} and hide the dialog box. - * @private - */ - _ok: function() - { - var form = this._form.getForm(); - if (!form.isValid()) - { - return; - } - - var title = form.findField('title').getValue(); - - if (Ext.isFunction (this._cbFn)) - { - this._cbFn (title); - } - - this._box.hide(); - } - -}); \ No newline at end of file Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/IndexedContentsTool.i18n.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/IndexedContentsTool.i18n.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/IndexedContentsTool.i18n.js (working copy) @@ -1,293 +0,0 @@ -/* - * Copyright 2013 Anyware Services - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * This tool display all contents indexed with a specific term of thesaurus - * @private - */ -Ext.define('Ametys.plugins.thesaurus.tool.IndexedContentsTool', { - extend: "Ametys.tool.Tool", - - statics: { - /** - * @property {Number} - * @readonly - * @static - * The number of records to display by 'page' - */ - PAGE_SIZE: 50 - }, - - /** - * @private - * @property {Ext.Template} _hintTpl The template for hint - */ - _hintTpl: Ext.create ('Ext.Template', ["", - "'{title}'", - "", - "{microthesaurus} ({thesaurus})" - ]), - - /** - * @private - * @property {Ext.Template} _titleTpl The template for tool's title - */ - _titleTpl: Ext.create ('Ext.Template', ["", "{title} ({microthesaurus}"]), - - /** - * @private - * @property {Ext.Template} _descriptionTpl The template for tool's description - */ - _descriptionTpl: Ext.create ('Ext.Template', ["", - "'{title}'", - "", - "{microthesaurus} ({thesaurus})" - ]), - - createPanel: function() - { - this.grid = this._createResultGrid(); - return this.grid; - }, - - setParams: function (params) - { - this.callParent(arguments); - - this._termId = params.id; - this.refresh(); - }, - - refresh: function () - { - this.callParent(arguments); - - this.showUpToDate(); - this._setGridDisabled(true); - - Ametys.data.ServerComm.callMethod({ - role: "org.ametys.plugins.thesaurus.ThesaurusDAO", - methodName: 'getTermInformation', - parameters: [this._termId], - errorMessage: "", - callback: { - handler: this._getTermInformationCb, - scope: this - } - }); - }, - - /** - * @private - * Callback function after retrieving term information - * @param {Object} result The JSON response - * @param {Object} args The callback arguments - */ - _getTermInformationCb: function (result, args) - { - this.setInfo ({ - title: this._titleTpl.applyTemplate (result), - description: this._descriptionTpl.applyTemplate (result) - }); - - var html = this._hintTpl.applyTemplate (result); - this.grid.getDockedItems('container[dock="top"]')[0].update(html); - - this.store.loadPage(1); - }, - - /** - * @protected - * Create the grid panel for results - * @return {Ext.grid.Panel} The created grid - */ - _createResultGrid: function () - { - this.store = this._createStore(); - - return Ext.create("Ametys.cms.content.EditContentsGrid", { - store: this.store, - - region: 'center', - - dockedItems: [{ - xtype: 'container', - cls: 'info', - dock: 'top', - html: '' - }], - - stateful: true, - stateId: this.self.getName() + "$grid", - - columns: [ - {id: this.self.getName().replace(/\./g, "_") + '-grid-title', header: "Titre", width: 170, sortable: false, dataIndex: 'title', editor: null, renderer: Ametys.cms.content.EditContentsGrid.renderTitle}, - {id: this.self.getName().replace(/\./g, "_") + '-grid-language', header: "Langue", width: 60, hidden: true, sortable: false, dataIndex: 'language', editor: null, renderer: Ametys.cms.content.EditContentsGrid.renderLanguage}, - {id: this.self.getName().replace(/\./g, "_") + '-grid-creator', header: "Créateur", width: 120, hidden: true, sortable: false, dataIndex: 'creator', editor: null, renderer: Ext.bind(Ametys.cms.content.EditContentsGrid.renderDisplay, null, ['creator'], true)}, - {id: this.self.getName().replace(/\./g, "_") + '-grid-contributor', header: "Auteur", width: 120, sortable: false, dataIndex: 'contributor', editor: null, renderer: Ext.bind(Ametys.cms.content.EditContentsGrid.renderDisplay, null, ['contributor'], true)}, - {id: this.self.getName().replace(/\./g, "_") + '-grid-lastModified', header: "Dernière modification", width: 120, sortable: false, dataIndex: 'lastModified', xtype: 'datecolumn', format: Ext.Date.patterns.FriendlyDateTime, editor: null}, - {id: this.self.getName().replace(/\./g, "_") + '-grid-workflowStep', header: "Etat", width: 60, sortable: false, dataIndex: 'workflowStep', editor: null, renderer: Ametys.cms.content.EditContentsGrid.renderWorkflowStep}, - {id: this.self.getName().replace(/\./g, "_") + '-grid-contentType', header: "Type de contenu", width: 180, sortable: false, dataIndex: 'contentType', editor: null} - ], - - messageTarget: Ametys.message.MessageTarget.CONTENT, - - selModel : { - mode: 'MULTI' - }, - - viewConfig: { - loadingText: "" - }, - - listeners: { - 'itemdblclick': {fn: function (view, record, item, index, e) { this.openContent(record); }, scope: this} - } - }); - }, - - /** - * Open content (on double-click for example) - * @param {Ext.data.Model} record The content to open - */ - openContent: function (record) - { - Ametys.cms.content.EditContentsGrid.openContent (record, { toolParams: {'tool-referrer-id': this.getId()}}); - }, - - sendCurrentSelection: function() - { - this.grid.sendCurrentSelection(); - }, - - getMBSelectionInteraction: function() - { - return Ametys.tool.Tool.MB_TYPE_ACTIVE; - }, - - /** - * @private - * Get the store the grid should use as its data source. - * @return {Ext.data.Store} The store - */ - _createStore: function () - { - return Ext.create('Ext.data.Store', { - model: 'Ametys.plugins.thesaurus.tool.IndexedContentsTool.ContentEntry', - remoteSort: false, - proxy: { - type: 'ametys', - plugin: 'thesaurus', - url: 'indexed-contents.xml', - reader: { - type: 'xml', - record: '> content', - root: 'contents' - } - }, - - pageSize: Ametys.plugins.thesaurus.tool.IndexedContentsTool.PAGE_SIZE, - sortOnLoad: true, - sorters: [{property: 'title', direction:'ASC'}], - - listeners: { - 'beforeload': {fn: this._onBeforeLoad, scope: this}, - 'load': {fn: this._onLoad, scope: this} - } - }); - }, - - /** - * Function called before loading the store - * @param {Ext.data.Store} store The store - * @param {Ext.data.Operation} operation The object that will be passed to the Proxy to load the store - * @private - */ - _onBeforeLoad: function (store, operation) - { - this.grid.getView().unmask(); - - operation.params = operation.params || {}; - operation.params.termIds = [this._termId]; - }, - - /** - * Function called after loading results - * @param {Ext.data.Store} store The store - * @param {Ext.data.Model[]} records An array of records - * @param {Boolean} successful True if the operation was successful. - * @private - */ - _onLoad: function (store, records, successful) - { - this._setGridDisabled(false); - - if (!successful) - { - Ametys.log.ErrorDialog.display({ - title: "", - text: "", - details: "", - category: "Ametys.plugins.thesaurus.tool.IndexedContentsTool" - }); - return; - } - - if (records.length == 0) - { - this.grid.getView().mask("", 'ametys-mask-unloading'); - } - - // TODO Save in navigation history - }, - - /** - * Enable or disable the grid columns and paging toolbar - * @param {Boolean} disabled true to disable. - * @private - */ - _setGridDisabled: function (disabled) - { - this.grid.getPageBar().setDisabled(disabled); - - var columns = this.grid.columnManager.getColumns(); - Ext.Array.each (columns, function (column) { - column.setDisabled(disabled); - }) - } -}); - -Ext.define('Ametys.plugins.thesaurus.tool.IndexedContentsTool.ContentEntry', { - extend: 'Ext.data.Model', - - fields: [ - {name: 'id', mapping: '@id'}, - {name: 'iconSmall', mapping: '@smallIcon'}, - {name: 'name', mapping: '@name'}, - {name: 'title', mapping: 'metadata/title', type: 'string', sortType: Ext.data.SortTypes.asNonAccentedUCString}, - {name: 'lastModified', type: 'date', mapping: 'lastModified'}, - {name: 'creatorDisplay', mapping: 'creatorDisplay'}, - {name: 'creator', mapping: 'creator', displayField: 'creatorDisplay'}, - {name: 'contributorDisplay', mapping: 'contributorDisplay'}, - {name: 'contributor', mapping: 'contributor', displayField: 'contributorDisplay'}, - {name: 'workflowStep', mapping: 'workflowStep'}, - {name: 'workflowStepId', mapping: 'workflowStep/@id'}, - {name: 'workflowStepIcon', mapping: 'workflow-icon-small'}, - {name: 'contentType', mapping: 'contentTypeOrMixin'}, - {name: 'language', mapping: 'contentLanguage'}, - {name: 'languageIcon', mapping: 'contentLanguageIcon'} - ] -}); \ No newline at end of file Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/IndexedContentsTool.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/IndexedContentsTool.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/IndexedContentsTool.js (working copy) @@ -98,10 +98,8 @@ */ _getTermInformationCb: function (result, args) { - this.setInfo ({ - title: this._titleTpl.applyTemplate (result), - description: this._descriptionTpl.applyTemplate (result) - }); + this.setTitle( this._titleTpl.applyTemplate(result) ); + this.setDescription( this._descriptionTpl.applyTemplate(result) ); var html = this._hintTpl.applyTemplate (result); this.grid.getDockedItems('container[dock="top"]')[0].update(html); @@ -195,7 +193,7 @@ reader: { type: 'xml', record: '> content', - root: 'contents' + rootProperty: 'contents' } }, @@ -213,15 +211,16 @@ /** * Function called before loading the store * @param {Ext.data.Store} store The store - * @param {Ext.data.Operation} operation The object that will be passed to the Proxy to load the store + * @param {Ext.data.operation.Operation} operation The object that will be passed to the Proxy to load the store * @private */ _onBeforeLoad: function (store, operation) { this.grid.getView().unmask(); - operation.params = operation.params || {}; - operation.params.termIds = [this._termId]; + operation.setParams(Ext.apply(operation.getParams() || {}, { + termIds: [this._termId] + })); }, /** Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/MicrothesaurusEntry.i18n.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/MicrothesaurusEntry.i18n.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/MicrothesaurusEntry.i18n.js (working copy) @@ -1,31 +0,0 @@ -/* - * Copyright 2014 Anyware Services - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * This class is the model for microthesaurii drop down list. See {@link Ametys.plugins.thesaurus.tool.ThesaurusTreePanel} - * @private - */ -Ext.define('Ametys.plugins.thesaurus.tool.MicrothesaurusEntry', { - extend: 'Ext.data.TreeModel', - - fields: [ - {name: 'id', mapping: '@id'}, - {name: 'label', mapping: '@label', type: 'string', sortType: Ext.data.SortTypes.asNonAccentedUCString}, - {name: 'text', mapping: '@label', type: 'string', sortType: Ext.data.SortTypes.asNonAccentedUCString} - ] - -}); - Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/SearchIndexedContentsTool.i18n.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/SearchIndexedContentsTool.i18n.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/SearchIndexedContentsTool.i18n.js (working copy) @@ -1,136 +0,0 @@ -/* - * Copyright 2014 Anyware Services - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * This tool is a search tool for contents indexed by specific terms - * @private - */ -Ext.define('Ametys.plugins.thesaurus.tool.SearchIndexedContentsTool', { - extend: "Ametys.plugins.cms.search.SearchTool", - - /** - * @private - * @property {Ext.Template} _hintTpl The template for hint - */ - _hintTpl: Ext.create ('Ext.Template', ["", - "{terms} ({microthesaurus})" - ]), - - constructor: function(config) - { - // do not open the content when only one result. - config.allowAutoOpenContent = false; - - // Not additional extension. - config.allowAdditionalExtensions = false; - - this.callParent(arguments); - }, - - /** - * @inheritdoc - */ - createPanel: function() - { - this.grid = this._createResultGrid(); - this.form = this._createSearchFormPanel(); - - var me = this; - this.mainPanel = Ext.create('Ext.panel.Panel', { - layout: 'border', - cls: 'search-indexed-contents-tool', - border: false, - items: [ this.form, this.grid ], - - listeners: { - 'resize': function (p, width, height) - { - // Set the max height of form panel - var maxHeight = Math.min(Ametys.plugins.cms.search.SearchTool.FORM_MAX_HEIGHT, parseInt(height * Ametys.plugins.cms.search.SearchTool.FORM_MAX_HEIGHT_RATIO)); - me.form.maxHeight = maxHeight; - - // Try to keep the current ratio if exists - if (me.form._heightRatio) - { - me.form.setHeight(me.form._heightRatio * height); - } - } - } - }); - - this.mainPanel.addDocked ({ - xtype: 'container', - cls: 'info', - dock: 'top', - html: '' - }); - - return this.mainPanel; - }, - - /** - * @inheritdoc - */ - getContextualParameters: function () - { - return { - contentId: this.getParams().contentId, - indexField: this.getParams().indexField - }; - }, - - /** - * @inheritdoc - */ - _initSearchForm: function(params) - { - this.callParent(arguments); - - // Update info - var termIds = this.form.getField('metadata-' + this.getParams().indexField + '-eq').getValue(); - termIds = Ext.isArray(termIds) ? termIds : [termIds]; - - Ametys.data.ServerComm.callMethod({ - role: "org.ametys.plugins.thesaurus.ThesaurusDAO", - methodName: 'getTermsInformation', - parameters: [termIds], - errorMessage: "", - callback: { - handler: this._updateInfoCb, - scope: this - } - }); - }, - - /** - * Callback function after retrieving information on terms - * @param {Object} result The JSON server response - * @private - */ - _updateInfoCb: function (result) - { - var terms = []; - var microthesaurus = ''; - - Ext.Array.each (result.terms, function (term) { - terms.push(term.title); - microthesaurus = term.microthesaurus; - }); - - var html = this._hintTpl.applyTemplate ({terms: terms.join(", "), microthesaurus: microthesaurus}); - this.mainPanel.getDockedItems('container[cls=info]')[0].update(html); - } -}); \ No newline at end of file Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/TermEntry.i18n.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/TermEntry.i18n.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/TermEntry.i18n.js (working copy) @@ -1,108 +0,0 @@ -/* - * Copyright 2014 Anyware Services - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * This class is the model for nodes of a thesaurus tree. See {@link Ametys.plugins.thesaurus.tool.ThesaurusTreePanel} - * @private - */ -Ext.define('Ametys.plugins.thesaurus.tool.TermEntry', { - extend: 'Ext.data.TreeModel', - - statics: { - /** - * @property {Ext.XTemplate} _tooltipTermTpl The tooltip term template - * @private - */ - _tooltipTermTpl: Ext.create('Ext.XTemplate', - "
", - "
{label}
", - "
", - "
", - "", - " : {tg}
", - "
", - "", - " : {ts}
", - "
", - "", - " : {ta}
", - "
", - "", - " : {synonyms}
", - "
", - "
", - "
", - "
" - ), - - /** - * @property {Ext.XTemplate} _tooltipCandidateTpl The tooltip candidate template - * @private - */ - _tooltipCandidateTpl: Ext.create('Ext.XTemplate', - "
", - "
{label}
", - "
", - "
", - "", - " : {comment:this.convertToHtml}
", - "
", - "
", - "
", - "
", - { - convertToHtml: function(value) - { - return value.replace(/\n/g, '
'); - } - } - ) - }, - - - fields: [ - {name: 'id', mapping: '@id'}, - {name: 'name', mapping: '@name'}, - {name: 'label', mapping: '@label', type: 'string', sortType: Ext.data.SortTypes.asNonAccentedUCString}, - {name: 'text', mapping: '@label', type: 'string', sortType: Ext.data.SortTypes.asNonAccentedUCString}, - {name: 'ta', mapping: '@ta'}, - {name: 'ts', mapping: '@ts'}, - {name: 'tg', mapping: '@tg'}, - {name: 'comment', mapping: '@comment', defaultValue: ''}, - {name: 'type', mapping: '@type ', defaultValue: 'term'}, - {name: 'synonyms', mapping: '@synonyms'}, - {name: 'leaf', type: 'boolean', mapping: '@leaf'}, - {name: 'qtip', persist: false, convert: function (v, record) { - if (record.get('type') == 'term') - { - return Ametys.plugins.thesaurus.tool.TermEntry._tooltipTermTpl.applyTemplate(record.data); - } - else if (record.get('type') == 'candidate') - { - return Ametys.plugins.thesaurus.tool.TermEntry._tooltipCandidateTpl.applyTemplate(record.data); - } - else - { - return null; - } - }}, - {name: 'cls', mapping: '@cls', defaultValue: ''}, - {name: 'iconCls', mapping: '@iconCls'}, - {name: 'iconLarge', mapping: '@iconLarge'} - ] - -}); - Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/TermEntry.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/TermEntry.js (revision 30361) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/TermEntry.js (working copy) @@ -31,16 +31,16 @@ "
{label}
", "
", "
", - "", + "", " : {tg}
", "
", - "", + "", " : {ts}
", "
", - "", + "", " : {ta}
", "
", - "", + "", " : {synonyms}
", "
", "
", @@ -85,14 +85,14 @@ {name: 'type', mapping: '@type ', defaultValue: 'term'}, {name: 'synonyms', mapping: '@synonyms'}, {name: 'leaf', type: 'boolean', mapping: '@leaf'}, - {name: 'qtip', persist: false, convert: function (v, record) { - if (record.get('type') == 'term') + {name: 'qtip', persist: false, calculate: function (data) { + if (data.type == 'term') { - return Ametys.plugins.thesaurus.tool.TermEntry._tooltipTermTpl.applyTemplate(record.data); + return Ametys.plugins.thesaurus.tool.TermEntry._tooltipTermTpl.applyTemplate(data); } - else if (record.get('type') == 'candidate') + else if (data.type == 'candidate') { - return Ametys.plugins.thesaurus.tool.TermEntry._tooltipCandidateTpl.applyTemplate(record.data); + return Ametys.plugins.thesaurus.tool.TermEntry._tooltipCandidateTpl.applyTemplate(data); } else { Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/ThesaurusTool.i18n.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/ThesaurusTool.i18n.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/ThesaurusTool.i18n.js (working copy) @@ -1,481 +0,0 @@ -/* - - * Copyright 2014 Anyware Services - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * This tool displays thesaurus - * @private - */ -Ext.define('Ametys.plugins.thesaurus.tool.ThesaurusTool', { - extend: "Ametys.tool.Tool", - - /** - * @property {String} _thesaurusId The id of thesaurus - * @private - */ - - /** - * @property {String} _thesaurusLabel The label of thesaurus - * @private - */ - constructor: function(config) - { - this.callParent(arguments); - - Ametys.message.MessageBus.on(Ametys.message.Message.SELECTION_CHANGED, this._onMessageSelectionChanged, this); - Ametys.message.MessageBus.on(Ametys.message.Message.MODIFIED, this._onMessageModified, this); - Ametys.message.MessageBus.on(Ametys.message.Message.CREATED, this._onMessageCreated, this); - Ametys.message.MessageBus.on(Ametys.message.Message.DELETED, this._onMessageDeleted, this); - }, - - getMBSelectionInteraction: function() - { - return Ametys.tool.Tool.MB_TYPE_ACTIVE; - }, - - sendCurrentSelection: function() - { - var node = this.getSelectedNode(); - - var termTargets = []; - - if (node != null && node.get('type') == 'term') - { - termTargets.push ({ - type: Ametys.message.MessageTarget.CONTENT, - parameters: { - ids: [node.getId()] - } - }); - } - - if (node != null && node.get('type') == 'candidate') - { - termTargets.push ({ - type: Ametys.message.MessageTarget.THESAURUS_CANDIDATE, - parameters: { - ids: [node.getId()] - } - }); - } - - var mtTargets = []; - if (!Ext.isEmpty(this.getMicrothesaurusId())) - { - mtTargets.push({ - type: Ametys.message.MessageTarget.MICROTHESAURUS, - parameters: { - id: this.getMicrothesaurusId(), - label: this._tree.getRootNode().get('label') - }, - subtargets: termTargets - }); - } - - Ext.create("Ametys.message.Message", { - type: Ametys.message.Message.SELECTION_CHANGED, - targets: { - type: Ametys.message.MessageTarget.THESAURUS, - parameters: { - id: this._thesaurusId, - label: this._thesaurusLabel - }, - subtargets: mtTargets - } - }); - }, - - setParams: function (params) - { - this.callParent (arguments); - - this._thesaurusId = params['id']; - this.refresh(); - }, - - createPanel: function() - { - var i = this.getId().indexOf('$') + 1; - var thesaurusId = this.getId().substring(i); - - this._tree = new Ametys.plugins.thesaurus.tool.ThesaurusTreePanel({ - region: 'center', - thesaurusId: thesaurusId, - tool: this, - rootVisible: true, - - viewConfig: { - plugins: { - ptype: 'ametystreeviewdragdrop', - containerScroll: true, - appendOnly: true, - sortOnDrop: true, - expandDelay: 500, - setAmetysDragInfos: Ext.bind(this.getDragInfo, this) - } - } - }); - - this._tree.on('selectionchange', this._onSelectNode, this); - this._tree.on('beforeitemdblclick', this._onItemDblClick, this); - - return this._tree; - }, - - /** - * @private - * This event is thrown by the getDragData to add the 'source' of the drag. - * @param {Object} item The default drag data that will be transmitted. You have to add a 'source' item in it: - * @param {Ametys.relation.RelationPoint} item.source The source (in the relation way) of the drag operation. - */ - getDragInfo: function(item) - { - var contentIds = []; - for (var i = 0; i < item.records.length; i++) - { - contentIds.push(item.records[i].get('id')); - } - - if (contentIds.length > 0) - { - item.source = { - relationTypes: [Ametys.relation.Relation.REFERENCE], - targets: { - type: Ametys.message.MessageTarget.CONTENT, - parameters: { ids: contentIds } - } - }; - } - }, - - /** - * This listener is called before the dblclick event on an node is processed. - * Open the term. - * @param {Ext.view.View} view The view - * @param {Ext.data.Model} record The record that belongs to the item - * @param {HTMLElement} item The item's element - * @param {Number} index The item's index - * @private - */ - _onItemDblClick: function (view, record, item, index) - { - if (record.get('type') == 'term') - { - Ametys.tool.ToolsManager.openTool('uitool-content', {'id': record.getId()}); - } - }, - - /** - * This function is called when a node is selected. - * @param {Ext.selection.Model} sm The selection model - * @param {Ext.data.NodeInterface[]} selected The selected nodes - * @private - */ - _onSelectNode: function (sm, selected) - { - if (selected.length == 0) - { - this._currentNode = null; - } - else - { - var node = selected[0]; - this._currentNode = node; - } - - this.sendCurrentSelection(); - }, - - refresh: function() - { - this.showRefreshing(); - this._updateInfos(); - }, - - /** - * Update tool information - * @private - */ - _updateInfos: function() - { - Ametys.data.ServerComm.callMethod({ - role: "org.ametys.plugins.thesaurus.ThesaurusDAO", - methodName: 'getThesaurusLabel', - parameters: [this._thesaurusId], - errorMessage: false, - callback: { - handler: this._updateInfosCb, - scope: this - } - }); - }, - - /** - * Callback function called after #_updateInfos is processed. - * Updates the tool's title and tooltip. - * @param {Object} result The server response. - * @param {Object[]} args The callback arguments - */ - _updateInfosCb: function (result, args) - { - if (result.error && result.error == "not-found") - { - Ametys.Msg.show({ - title: "", - msg: "", - buttons: Ext.Msg.OK, - icon: Ext.Msg.ERROR, - fn: function (btn) - { - this.showRefreshed(); - this.close(); - }, - scope: this - }); - - return; - } - - this._thesaurusLabel = result.label; - - this.setInfo ({ - title: result.label - }); - - this._tree.loadMicrothesaurii (null, Ext.bind(this._refreshCb, this)); - }, - - /** - * Callback function after refresh - * @private - */ - _refreshCb: function () - { - this.showRefreshed(); - }, - - /** - * Get the tree panel - * @return {Ametys.plugins.thesaurus.tool.ThesaurusTreePanel} The tree - */ - getTree: function () - { - return this._tree; - }, - - /** - * Get the current selected node - * @return {Ext.data.NodeInterface} The selected node - */ - getSelectedNode: function() - { - return this.getTree().getSelectionModel().getSelection()[0]; - }, - - /** - * Get the id of selected node in the tree. - * If no node is selected, returns the id of the current microthesaurus - */ - getSelectedNodeId: function() - { - var node = this.getSelectedNode(); - - return node != null ? node.getId() : null; - }, - - /** - * Get the thesaurus id - * @return {String} the thesaurus id - */ - getThesaurusId: function() - { - return this._thesaurusId; - }, - - /** - * Get the thesaurus id - * @return {String} the thesaurus id - */ - getMicrothesaurusId: function() - { - return this._tree.getMTComboBox().getValue(); - }, - - /** - * Get the selected microthesaurus - * @return {Ametys.plugins.thesaurus.tool.MicrothesaurusEntry} the microthesaurus - */ - getSelectedMT: function () - { - return this._tree.getSelectedMT(); - }, - - /** - * Listener when a Ametys.message.Message#SELECTION_CHANGED message was received - * @param {Ametys.message.Message} message The selection message - * @private - */ - _onMessageSelectionChanged: function (message) - { - var target = message.getTarget(Ametys.message.MessageTarget.CONTENT); - if (target != null && this._isOnCurrentTree(target.getParameters().additionalData.thesaurusId, target.getParameters().additionalData.microthesaurusId)) - { - var node = this._tree.getStore().getNodeById(target.getParameters().id); - if (node && this._tree.getSelectionModel().isSelected(node)) - { - // Same selection - return; - } - - var me = this; - this._tree.suspendEvent('selectionchange'); - this._tree.selectNodesByPath ([target.getParameters().additionalData.path], null, function () { - me._tree.resumeEvent('selectionchange'); - }); - } - }, - - /** - * Listener when a Ametys.message.Message#MODIFIED message was received - * @param {Ametys.message.Message} message The modified message - * @private - */ - _onMessageModified: function (message) - { - var target = message.getTarget(Ametys.message.MessageTarget.THESAURUS); - if (target != null && this._isOnCurrentTree(target.getParameters().id)) - { - this._updateInfos(); - return; - } - - var target = message.getTarget(Ametys.message.MessageTarget.MICROTHESAURUS); - if (target != null && this._isOnCurrentTree(target.getParameters().thesaurusId)) - { - // TODO ne pas recharger l'arbre - this._tree.loadMicrothesaurii (target.getParameters().id); - return; - } - - target = message.getTarget(new RegExp("^" + Ametys.message.MessageTarget.CONTENT + "|" + Ametys.message.MessageTarget.THESAURUS_CANDIDATE + "$")); - if (target != null) - { - var node = this._tree.getStore().getNodeById(target.getParameters().id); - if (node) - { - node.set('text', target.getParameters().title); - node.commit(); - } - this._tree.refreshNode (target.getParameters().id); - } - }, - - /** - * Listener when a Ametys.message.Message#CREATED message was received - * @param {Ametys.message.Message} message The modified message - * @private - */ - _onMessageCreated: function (message) - { - var target = message.getTarget(Ametys.message.MessageTarget.MICROTHESAURUS); - if (target != null && this._isOnCurrentTree(target.getParameters().thesaurusId)) - { - this._tree.loadMicrothesaurii (target.getParameters().id); - return; - } - - var target = message.getTarget(Ametys.message.MessageTarget.CONTENT); - if (target != null && this._isOnCurrentTree(target.getParameters().additionalData.thesaurusId, target.getParameters().additionalData.microthesaurusId)) - { - // Force leaf to false on parent node - var node = this._tree.getStore().getNodeById(target.getParameters().additionalData.parentId); - if (node != null) - { - node.set('leaf', false); - } - // Then refresh parent node - this._tree.refreshNode (target.getParameters().additionalData.parentId || target.getParameters().additionalData.microthesaurusId); - } - - var target = message.getTarget(Ametys.message.MessageTarget.THESAURUS_CANDIDATE); - if (target != null && this._isOnCurrentTree(target.getParameters().additionalData.thesaurusId, target.getParameters().additionalData.microthesaurusId)) - { - var node = this._tree.getStore().getNodeById(target.getParameters().additionalData.parentId); - if (node != null) - { - // Then refresh parent node - this._tree.refreshNode (target.getParameters().additionalData.parentId); - } - else - { - // Root node for candidates does not exist, refresh root node - this._tree.refreshNode (this._tree.getRootNode().getId()); - } - } - }, - - /** - * Listener when a Ametys.message.Message#DELETED message was received - * @param {Ametys.message.Message} message The modified message - * @private - */ - _onMessageDeleted: function (message) - { - var target = message.getTarget(Ametys.message.MessageTarget.THESAURUS); - if (target != null && target.getParameters().id == this._thesaurusId) - { - this.close(); - return; - } - - var target = message.getTarget(Ametys.message.MessageTarget.MICROTHESAURUS); - if (target != null && this._isOnCurrentTree(target.getParameters().thesaurusId)) - { - this._tree.loadMicrothesaurii (); - return; - } - - var target = message.getTarget(Ametys.message.MessageTarget.CONTENT); - if (target != null && this._isOnCurrentTree(target.getParameters().additionalData.thesaurusId, target.getParameters().additionalData.microthesaurusId)) - { - this._tree.deleteNode (target.getParameters().id); - } - - var target = message.getTarget(Ametys.message.MessageTarget.THESAURUS_CANDIDATE); - if (target != null && this._isOnCurrentTree(target.getParameters().additionalData.thesaurusId, target.getParameters().additionalData.microthesaurusId)) - { - this._tree.deleteNode (target.getParameters().id); - } - }, - - /** - * Determines if the tool is concerned with the last update - * @param {String} thesaurusId The id of thesaurus concerned with the update - * @param {String} microthesaurusId The id of microthesaurus concerned with the update. Can be null. - * @return {Boolean} true if the tool is concerned with the last update - * @private - */ - _isOnCurrentTree: function (thesaurusId, microthesaurusId) - { - if (thesaurusId == null || this._thesaurusId != thesaurusId) - { - return false; - } - - return microthesaurusId == null || this.getMicrothesaurusId() == microthesaurusId; - } -}); - Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/ThesaurusTool.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/ThesaurusTool.js (revision 30361) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/ThesaurusTool.js (working copy) @@ -103,6 +103,7 @@ this.callParent (arguments); this._thesaurusId = params['id']; + this._thesaurusLabel = params['label']; this.refresh(); }, @@ -251,9 +252,7 @@ this._thesaurusLabel = result.label; - this.setInfo ({ - title: result.label - }); + this.setTitle(result.label); this._tree.loadMicrothesaurii (null, Ext.bind(this._refreshCb, this)); }, Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/ThesaurusTreePanel.i18n.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/ThesaurusTreePanel.i18n.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/ThesaurusTreePanel.i18n.js (working copy) @@ -1,1076 +0,0 @@ -/* - * Copyright 2014 Anyware Services - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * This class provides a TreePanel for thesaurus - * The tree includes a toolbar which allow to : - * - filter resources on name, - * - refresh a node - * - expand a node - * - collapse the all tree. - * The default tree store uses the {@link Ametys.plugins.thesaurus.tool.TermEntry} model. Override the #createTreeStore method to use another Model. - * @private - */ -Ext.define('Ametys.plugins.thesaurus.tool.ThesaurusTreePanel', { - extend: 'Ext.tree.Panel', - - /** - * @cfg {String} thesaurusId The id of root thesaurus - */ - - /** - * @property {String} _thesaurusId See {#cfg-thesaurusId} - * @private - */ - - /** - * @cfg {String} microthesaurusId The id of microthesaurus. Can be null to choose microthesaurus in a list - */ - - /** - * @property {String} _microthesaurusId See {#cfg-microthesaurusId} - */ - - /** - * @cfg {Boolean} hideCandidates=false Set to true to hide candidates - */ - - /** - * @property {Boolean} _hideCandidates See {#cfg-hideCandidates} - */ - - /** - * @cfg {Boolean} checkMode=false To select terms by checkboxes - */ - checkMode : false, - - cls: 'thesaurus-tree', - - /** - * @cfg {String} The css class for synonym node - */ - synonymCls: 'synonym', - - statics: { - /** - * The default filter. - */ - DEFAULT_FILTER: function(node) - { - return node ? true : false; - } - }, - - initComponent: function () - { - Ext.apply(this, { - folderSort: false, - root: { - text: "", - hasChild: true, - editable: false, - allowDrag: false, - allowDrop: false, - expanded: true, - name: '', - type: 'microthesaurus', - iconCls: 'tree-icon-microthesaurus', - loaded: true // Prevent AJAX request - }, - store: this.createTreeStore() - }); - - this.callParent(); - }, - - constructor: function (config) - { - this._thesaurusId = config.thesaurusId; - this._microthesaurusId = config.microthesaurusId; - this._hideCandidates = config.hideCandidates || false; - - config.rootVisible = config.rootVisible || false; - - // Docked items - config.dockedItems = this.getDockItems(config); - - // No result panel - var noResultPanelCfg = this._getNoResultPanelCfg(); - if (noResultPanelCfg) - { - noResultPanelCfg.dock = noResultPanelCfg.dock || 'top'; - config.dockedItems.push(noResultPanelCfg); - } - - this._filterConfig = config.filter || Ametys.plugins.thesaurus.tool.ThesaurusTreePanel.DEFAULT_FILTER; - - this._counter = {}; - this._filterValue = null; - - this.callParent(arguments); - - if (this.checkMode) - { - this.on ('beforeitemappend', this._setCheckedProperty, this); - } - }, - - /** - * @private - * Listen to the beforeappend event of the tree store, to set the 'checked' property on node - * @param {Ext.data.NodeInterface} node The current node - * @param {Ext.data.NodeInterface} child The child node to be appended - */ - _setCheckedProperty: function(node, child) - { - var type = child.get('type'); - if (type == 'term' || type == 'candidate') - { - child.set('checked', false); - } - }, - - /** - * Get the dock items - * @param {Object} config The initial tree panel configuration - * @return {Object[]} The dock items configuration - */ - getDockItems: function (config) - { - var dockedItems = config.dockedItems || []; - - if (!this._microthesaurusId) - { - var comboCfg = this._getMicroThesaurusComboCfg(); - comboCfg.dock = comboCfg.dock || 'top'; - dockedItems.push(comboCfg); - } - - var topToolbarCfg = this._getTopToolbarCfg(); - if (topToolbarCfg) - { - topToolbarCfg.dock = topToolbarCfg.dock || 'top'; - dockedItems.push(topToolbarCfg); - } - - var bottomToolbarCfg = this._getBottomToolbarCfg(); - if (bottomToolbarCfg) - { - bottomToolbarCfg.dock = bottomToolbarCfg.dock || 'bottom'; - dockedItems.push(bottomToolbarCfg); - } - - return dockedItems; - }, - - /** - * Returns the combo box of microthesaurii - * @return {Ext.form.ComboBox} The combo box - */ - getMTComboBox: function () - { - return this.getDockedItems('form[dock="top"]')[0].down('combo'); - }, - - /** - * Get the selected MicroThesaurus - * @return {Ametys.plugins.thesaurus.tool.MicrothesaurusEntry} the microthesaurus - */ - getSelectedMT: function() - { - return this._microThesaurusStore.getById(this.getMTComboBox().getValue()); - }, - - /** - * @protected - * Get configuration object for combox box of microthesaurii - * @return {Ext.form.ComboBox} The combo box - */ - _getMicroThesaurusComboCfg: function () - { - this._microThesaurusStore = Ext.create('Ext.data.Store', { - model: 'Ametys.plugins.thesaurus.tool.MicrothesaurusEntry', - sortOnLoad: true, - sorters: [{property: 'label', direction:'ASC'}], - proxy: { - type: 'ametys', - plugin: 'thesaurus', - url: 'microthesaurus-list', - extraParams: {id: this._thesaurusId}, - reader: { - type: 'xml', - record: '> Node' - } - }, - autoLoad: false - }); - - return { - xtype: 'form', - border: false, - layout: 'column', - cls: 'thesaurus-tree-form', - - items: [{ - xtype: 'combobox', - columnWidth: 1, - - typeAhead: true, - forceSelection: true, - triggerAction: 'all', - cls: 'ametys', - - labelSeparator: '', - labelWidth: 90, - name: 'microthesaurus', - fieldLabel: "", - store: this._microThesaurusStore, - valueField: 'id', - displayField: 'label', - - listConfig: { - cls: 'ametys-boundlist' - }, - - listeners: { - 'select': Ext.bind (this._microThesaurusComboSelect, this) - } - }] - } - }, - - /** - * @protected - * Retrieves the bottom toolbar config object. - */ - _getBottomToolbarCfg: function() - { - if (!this._hideCandidates) - { - return { - xtype: 'panel', - layout: 'column', - border: false, - cls: 'thesaurus-tree-toolbar', - defaultType: 'button', - items: [{ - // Add candidate - text: "", - tooltip: "", - handler: Ext.bind (this._createCandidate, this), - icon: Ametys.getPluginResourcesPrefix('thesaurus') + '/img/actions/add_candidate_16.png', - cls: 'x-btn-text-icon' - }] - }; - } - return null; - }, - - /** - * @protected - * Retrieves the top toolbar config object. - */ - _getTopToolbarCfg: function() - { - return { - xtype: 'panel', - layout: 'column', - border: false, - cls: 'thesaurus-tree-toolbar', - defaultType: 'button', - items: [{ - // Search input - xtype: 'textfield', - columnWidth: 1, - itemId: 'search-filter-input', - emptyText: "", - enableKeyEvents: true, - minLength: 3, - minLengthText: "", - msgTarget: 'qtip', - listeners: {keyup: { fn: this._onKeyUp, scope: this, delay: 500}} - }, - { - // Clear filter - width: 20, - tooltip: "", - handler: Ext.bind (this._clearSearchFilter, this), - icon: Ametys.getPluginResourcesPrefix('cms') + '/img/tree/clear.gif', - cls: 'x-btn-text-icon', - style: { - marginRight: '20px' - } - }, - { - // Expand node - width: 20, - tooltip: "", - handler: Ext.bind (this._expandNode, this, [], false), - icon: Ametys.getPluginResourcesPrefix('cms') + '/img/tree/expand-all.gif', - cls: 'x-btn-text-icon' - }, - { - // Collapse all - width: 20, - tooltip: "", - handler: Ext.bind (this.collapseAll, this), - icon: Ametys.getPluginResourcesPrefix('cms') + '/img/tree/collapse-all.gif', - cls: 'x-btn-text-icon' - }, - { - // Refresh node - width: 20, - tooltip: "", - handler: Ext.bind (this.refreshNode, this, [], false), - icon: Ametys.getPluginResourcesPrefix('cms') + '/img/tree/refresh.png', - cls: 'x-btn-text-icon' - } - ] - }; - }, - - /** - * Create candidate - * @param {Ext.Button} btn The button - * @private - */ - _createCandidate: function(btn) - { - Ametys.plugins.thesaurus.helper.EditCandidateHelper.open (Ametys.getPluginResourcesPrefix('thesaurus') + '/img/actions/add_candidate_16.png', - "", Ext.bind(this._doCreateCandidate, this)); - }, - - /** - * @private - * Creates a new candidate - * @param {String} label The label - * @param {String} comment The comment - */ - _doCreateCandidate: function (label, comment) - { - var microthesaurusId = this.getRootNode().getId(); - - Ametys.data.ServerComm.callMethod({ - role: "org.ametys.plugins.thesaurus.ThesaurusDAO", - methodName: 'createCandidate', - parameters: [label, comment, 'fr', microthesaurusId], // FIXME fr hard coded - errorMessage: "", - callback: { - handler: this._createCandidateCb, - scope: this - } - }); - }, - - /** - * @private - * Callback function after creating candidate - * @param {Object} result The result object - * @param {Object[]} args The callback arguments - */ - _createCandidateCb: function(result, args) - { - var checkedNodesBeforeRefresh = this.checkMode ? this.getChecked() : []; - - var node = this.getStore().getNodeById(result.parentId); - if (node != null) - { - // Refresh parent node - this.refreshNode (result.parentId, Ext.bind (this._checkNodesAfterRefresh, this, [checkedNodesBeforeRefresh], true)); - } - else - { - // Root node for candidates does not exist, refresh root node - this.refreshNode (this.getRootNode().getId(), Ext.bind (this._checkNodesAfterRefresh, this, [checkedNodesBeforeRefresh], true)); - } - }, - - /** - * Check nodes after a refresh - * @param {Ext.data.NodeInterface} node The refreshed node - * @param {Ext.data.NodeInterface[]} checkedNodes The checked nodes before refreshing - * @private - */ - _checkNodesAfterRefresh: function (node, checkedNodes) - { - if (checkedNodes.length > 0) - { - var paths = []; - Ext.Array.each (checkedNodes, function (node) { - paths.push (node.getPath('name').substring(1)); - }) - - this.expandNodesByPath(paths, node, function (success, lastNode) { - if (success) - { - lastNode.set('checked', true); - } - }); - } - }, - - /** - * @protected - * Retrieves the 'no result' panel config - */ - _getNoResultPanelCfg: function() - { - var html = ""; - html += this._hideCandidates ? "" : "" - - var cfg = { - xtype: 'component', - itemId: 'noresult', - cls: 'no-result-panel', - hidden: true, - html: html, - listeners: { - click: { - fn: this._hideCandidates ? this._clearSearchFilter : this._createCandidateFromFilter, - scope: this, - element: 'el' - } - } - }; - - return cfg; - }, - - /** - * This listener is called on 'keyup' event on filter input field. - * Filters the tree by text input. - * @param {Ext.form.Field} field The field - * @private - */ - _onKeyUp: function (field) - { - var value = new String(field.getValue()).trim(); - this._filterField = field; - - if (this._filterValue == value) - { - // Do nothing - return; - } - - this._filterValue = value; - - if (value.length > 2) - { - var rootNode = this.getRootNode(); - this._getFilteredTerms (value, rootNode); - } - else - { - this._hideNoResultPanel(); - this.clearFilter(); - } - }, - - /** - * Clear all filters - */ - clearFilter: function (node) - { - node = node || this.getRootNode(); - - var view = this.getView(); - - node.cascadeBy( function(node) { - if (node.get('cls') == this.synonymCls) - { - node.set('cls',''); - } - var uiNode = view.getNodeByRecord(node); - - if (uiNode) - { - this._filterConfig(node) ? Ext.get(uiNode).setDisplayed('table-row') : Ext.get(uiNode).setDisplayed('none'); - } - }, this); - }, - - /** - * Filters by a set of function. The specified function will be called for each Record in this Store. - * If the function returns true the Record is included, otherwise it is filtered out. - * @param {Function/Function[]} filterFn A function or a set of functions to be called. It will be passed the following parameters: - * @param {Ext.data.Model} [node=root node] The node to test for filtering - */ - filterBy: function (filterFn, node) - { - node = node || this.getRootNode(); - - if (!Ext.isArray(filterFn)) - { - filterFn = [filterFn]; - } - - var view = this.getView(); - - node.cascadeBy( function (node) { - - var uiNode = view.getNodeByRecord(node); - - var display = true; - for (var i=0; i < filterFn.length; i++) - { - display = display && filterFn[i](node); - } - - if (uiNode) - { - display ? Ext.get(uiNode).setDisplayed('table-row') : Ext.get(uiNode).setDisplayed('none'); - } - }, this); - - var selection = this.getSelectionModel().getSelection(); - var currentNode = selection.length > 0 ? selection[0] : null; - if (currentNode) - { - var uiNode = this.getView().getNodeByRecord(currentNode); - if (!uiNode || Ext.get(uiNode) == null || !Ext.get(uiNode).isVisible(true)) - { - this.getSelectionModel().deselectAll(); - } - } - }, - - /** - * Get the terms the name matches the given value - * @param {String} value The value to match - * @param {Ext.data.Model} rootNode The root node - * @param {Ext.data.Model} node The initial node to search from. Can be null. If null start from root node. - * @param {Function} [callback] The function called on server response. Transmited to #_filterTermsCb. - * @private - */ - _getFilteredTerms: function (value, rootNode, node, callback) - { - node = node || rootNode; - - Ametys.data.ServerComm.callMethod({ - role: "org.ametys.plugins.thesaurus.ThesaurusDAO", - methodName: 'filterTermsByRegExp', - parameters: [value, node.getId()], - errorMessage: "", - callback: { - handler: this._filterTermsCb, - scope: this, - arguments: { - node: node, - callback: callback - } - } - }); - }, - - /** - * @private - * Callback function after searching terms - * @param {Object} result The result object - * @param {Object[]} args The callback arguments - */ - _filterTermsCb: function(result, args) - { - var paths = result.paths; - var hasResult = false; - var node = args.node || this.getRootNode(); - var callback = args.callback; - - if (!paths) - { - return; - } - - - if (paths.length == 0) - { - this.filterBy (function () {return false}); - } - else - { - hasResult = true; - this._expandAndFilter (paths, this.getRootNode(), node); - } - - if (!hasResult) - { - this._showNoResultPanel(); - this.getSelectionModel().deselectAll(); - Ext.defer (this._filterField.markInvalid, 100, this._filterField, [""]); - } - else - { - this._hideNoResultPanel(); - this._filterField.clearInvalid(); - } - - if (Ext.isFunction(callback)) - { - callback(); - } - }, - - /** - * Create a new candidate from filter value - * @param {Ext.Button} btn The clicked button - * @private - */ - _createCandidateFromFilter: function (btn) - { - var topItems = this.getDockedItems('panel[dock="top"]'); - var filterValue = topItems[topItems.length - 1].down('#search-filter-input').getValue(); - - var me = this; - Ametys.plugins.thesaurus.helper.EditCandidateHelper.open (Ametys.getPluginResourcesPrefix('thesaurus') + '/img/actions/add_candidate_16.png', - "", function (label, comment) { - me._clearSearchFilter(); - me._doCreateCandidate(label, comment); - }, - filterValue); - }, - - /** - * Clear the filter search - * @param {Ext.Button} btn The button - * @private - */ - _clearSearchFilter: function(btn) - { - this.clearFilter(); - - var topItems = this.getDockedItems('panel[dock="top"]'); - topItems[topItems.length - 1].down('#search-filter-input').reset(); - - this._filterValue = null; - - this._hideNoResultPanel(); - }, - - /** - * Hide the panel showing there is no result. - * @private - */ - _hideNoResultPanel: function () - { - var noResultPanel = this.getDockedItems('#noresult')[0]; - if (noResultPanel) - { - noResultPanel.hide(); - } - }, - - /** - * Show the panel showing there is no result. - * @private - */ - _showNoResultPanel: function () - { - var noResultPanel = this.getDockedItems('#noresult')[0]; - if (noResultPanel) - { - noResultPanel.show(); - } - }, - - /** - * Expand the tree to the given paths. Then filter nodes matching the given paths by calling the #_filterPaths method - * @param {Object[]} paths The paths to expand - * @param {Ext.data.Model} rootNode The concerned root node - * @param {Ext.data.Model} node The node from which apply filter - * @private - */ - _expandAndFilter: function(paths, rootNode, node) - { - node = node || rootNode; - - this._counter[rootNode.getId()] = paths.length; - for (var i=0; i < paths.length; i++) - { - var path = paths[i].path; - this.expandPath (rootNode.getPath('name') + '/' + paths[i].path, 'name', null, Ext.bind (this._filterPaths, this, [paths, rootNode, node, paths[i].matchSynonyms || false], true)); - } - }, - - /** - * Filter nodes by path once the last expand has been processed - * @param {Boolean} success true if the expand was successful - * @param {Ext.data.Model} lastNode the last node that was expanded - * @param {String[]} paths The path to filter by - * @param {Ext.data.Model} rootNode The concerned root node - * @param {Ext.data.Model} node The node from which apply filter - * @param {Boolean} matchSynonyms 'true' if the filter matched thank to synomyns - * @private - */ - _filterPaths: function (success, lastNode, paths, rootNode, node, matchSynonyms) - { - if (matchSynonyms) - { - lastNode.set('cls', this.synonymCls); - } - - // only execute the filterBy after the last expandPath() - if (--this._counter[rootNode.getId()] == 0) - { - var filterFn = Ext.bind (this._filterByPath, this, [paths, rootNode], true); - - // FIXME Ensure that expand is complete by deferring the filterBy function ... - Ext.defer(this.filterBy, 50, this, [filterFn, node]); - } - - }, - - /** - * Returns true if the node path is a part of given paths - * @param {Ext.data.Model} node The node to test - * @param {String[]} paths The paths - * @param {Ext.data.Model} rootNode The root node to build the complete paths - * @private - */ - _filterByPath: function (node, paths, rootNode) - { - var currentPath = node.getPath('name'); - for (var i=0; i < paths.length; i++) - { - var path = rootNode.getPath('name') + '/' + paths[i].path; - if (path.indexOf(currentPath + '/') == 0) - { - return true; - } - - if (path == currentPath) - { - return this._filterConfig(node); - } - } - return false; - }, - - /** - * @protected - * Create the tree store - * @param {Object} config The tree panel configuration - * @return {Ext.data.TreeStore} The created tree store - */ - createTreeStore: function (config) - { - var store = Ext.create('Ext.data.TreeStore', Ext.apply({ - model: 'Ametys.plugins.thesaurus.tool.TermEntry', - proxy: { - type: 'ametys', - plugin: 'thesaurus', - url: 'microthesaurus-nodes', - reader: { - type: 'xml', - root: 'Nodes', - record: '> Node' - } - } - }, this._getStoreSortInfo())); - - store.addListener ('beforeload', this._onStoreBeforeLoad, this); - return store; - - }, - - /** - * @private - * Set the request parameters before loading the store. - * @param {Ext.data.Store} store The store. - * @param {Ext.data.Operation} operation The Ext.data.Operation object that will be passed to the Proxy to load the Store. - */ - _onStoreBeforeLoad: function (store, operation) - { - operation.params = operation.params || {}; - operation.params.hideCandidates = this._hideCandidates; - }, - - /** - * @protected - * Must return an object containing sort configuration property for the internal {@link Ext.data.TreeStore} - */ - _getStoreSortInfo: function() - { - return { - sorters: [{ - sorterFn: function(o1, o2){ - if (o1.data.type == 'root-candidates') - { - return 1; - } - else if (o2.data.type == 'root-candidates') - { - return -1; - } - else - { - return 0; - } - } - }, - // Alphabetical sort - {property: 'text', direction:'ASC'}] - }; - }, - - /** - * Get the current selected node (folder) - * @return {Ext.data.NodeInterface} The selected node - */ - getSelectedNode: function() - { - return this.getSelectionModel().getSelection()[0]; - }, - - /** - * Load the microthesaurii - * @param {String} [microThesaurusId] The id of microthesaurus to select after loading. Can be null. - * @param {Function} [callback] The callback function to call after loading success - */ - loadMicrothesaurii: function (microThesaurusId, callback) - { - if (!this._microthesaurusId) - { - // Load microthesaurus combobox - Ext.apply(this._microThesaurusStore.getProxy().extraParams, {id: this._thesaurusId}); - - this._microThesaurusStore.load({ - scope: this, - callback: function(records, operation, success) { - if (this._microThesaurusStore.getCount() >= 1) - { - var selectedMT = microThesaurusId != null ? this._microThesaurusStore.getById(microThesaurusId) : this._microThesaurusStore.getAt(0); - - var selectedMTId = selectedMT.get(this.getMTComboBox().valueField, true); - var selectedMTLabel = selectedMT.get(this.getMTComboBox().displayField, true); - - var rootNode = this.getRootNode(); - rootNode.set('text', selectedMTLabel); - rootNode.set('label', selectedMTLabel); - rootNode.set('name', ''); - rootNode.setId (selectedMTId); - rootNode.commit(); - - this.getMTComboBox().setValue(selectedMTId); - this.getSelectionModel().deselectAll(); - - this.getStore().load({ - params: { - node: selectedMTId - }, - scope:this, - callback: function (records, operation, success) { - - this.getSelectionModel().select(this.getRootNode()); - - if (Ext.isFunction(callback)) - { - callback(); - } - } - }); - } - else - { - if (Ext.isFunction(callback)) - { - callback(); - } - } - } - }); - } - else - { - var rootNode = this.getRootNode(); - rootNode.set('name', ''); - rootNode.setId (this._microthesaurusId); - rootNode.commit(); - - this.getStore().load({ - params: { - node: this._microthesaurusId - }, - scope:this, - callback: function (records, operation, success) { - - this.getSelectionModel().select(this.getRootNode()); - - if (Ext.isFunction(callback)) - { - callback(); - } - } - }); - } - - }, - - /** - * Deletes a node from the tree and selects the parent node. - * @param {String} id The id of the node to delete. - * @private - */ - deleteNode: function(id) - { - var node = this.getStore().getNodeById(id); - - if (node != null) - { - var parentNode = node.parentNode; - this.getSelectionModel().select([parentNode]); - node.remove(); - } - }, - - /** - * This function reload the given node - * @param {String} id The id of the node to reload - * @param {Function} callback The callback function to call after reload. Can be null. Has the following parameters: - * @param {Ext.data.Model} callback.node The refreshed node - */ - refreshNode: function (id, callback) - { - var node; - if (id == null) - { - var selection = this.getSelectionModel().getSelection(); - node = selection.length > 0 ? selection[0] : null; - - // Workaround - Refresh selection in case node is not existing anymore (deleted by another user for example). - this.getSelectionModel().deselect(node); - this.getSelectionModel().select(node); - } - else - { - node = this.getStore().getNodeById(id); - } - - if (node != null) - { - // Set leaf to false, to allow children to be added during the load. Leaf will be set to true again if needed after the load. - node.set('leaf', false); - - this.getStore().load({ - node: node, - callback: function() { - - if (this._filterValue && this._filterValue.length > 2) - { - this._getFilteredTerms (this._filterValue, this.getRootNode(), node, callback ? Ext.bind(callback, null, [node]) : null); - } - else - { - Ext.defer(this._expandNode, 200, this, [node, callback]); - } - - - }, - scope: this - }); - } - }, - - /** - * Expand the given node - * @param {String} node The node to expand. - * @param {Function} callback The callback function to call after reload. Can be null. Has the following parameters: - * @param {Ext.data.Model} callback.node The expended node - * @private - */ - _expandNode: function (node, callback) - { - if (node == null) - { - var selection = this.getSelectionModel().getSelection(); - node = selection.length > 0 ? selection[0] : null; - } - - if (node != null) - { - if (!node.hasChildNodes()) - { - node.set('leaf', true); - } - - callback = callback ? Ext.bind(callback, null, [node]) : null; - this.expandNode (node, false, callback); - } - }, - - /** - * @private - * Listener when a item is selected in the list. Reload the tree. - * @param {Ext.form.field.ComboBox} combo The combox box - * @param {Array} records The selected records - * @param {Object} eOpts The options - */ - _microThesaurusComboSelect: function(combo, records, eOpts) - { - this.getSelectionModel().deselectAll(); - this._clearSearchFilter(); - - var rootNode = this.getRootNode(); - rootNode.setId (records[0].getId()); - rootNode.set ('text', records[0].get ('label')); - rootNode.set ('label', records[0].get ('label')); - rootNode.set('name', ''); - rootNode.commit(); - - this.getStore().load({ - params: { - node: records[0].getId() - }, - scope:this, - callback: function (records, operation, success) { - this.getSelectionModel().select(this.getRootNode()); - } - }); - }, - - /** - * Expand the tree to the given paths. - * @param {String[]} paths The paths to expand - * @param {Ext.data.Model} rootNode The concerned root node - * @param {Function} callback The callback function to call after expand. Can be null. - */ - expandNodesByPath: function(paths, rootNode, callback) - { - var rootNode = rootNode || this.getRootNode(); - - for (var i=0; i < paths.length; i++) - { - this.expandPath (rootNode.getPath('name') + '/' + paths[i], 'name', null, callback); - } - }, - - /** - * Select a node in the tree. The full AmetysObject path is required. - * @param {String[]} paths The paths of node to select - * @param {Ext.data.Model} rootNode The concerned root node - * @param {Function} callback The callback function to call after selection. Can be null. - */ - selectNodesByPath: function(paths, rootNode, callback) - { - var rootNode = rootNode || this.getRootNode(); - - for (var i=0; i < paths.length; i++) - { - this.selectPath (rootNode.getPath('name') + '/' + paths[i], 'name', null, callback); - } - } - -}); - Index: main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/ThesaurusTreePanel.js =================================================================== --- main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/ThesaurusTreePanel.js (revision 32275) +++ main/plugin-thesaurus/resources/js/Ametys/plugins/thesaurus/tool/ThesaurusTreePanel.js (working copy) @@ -78,18 +78,7 @@ { Ext.apply(this, { folderSort: false, - root: { - text: "", - hasChild: true, - editable: false, - allowDrag: false, - allowDrop: false, - expanded: true, - name: '', - type: 'microthesaurus', - iconCls: 'tree-icon-microthesaurus', - loaded: true // Prevent AJAX request - }, + root: this._getInitRootConfig(), store: this.createTreeStore() }); @@ -326,7 +315,7 @@ // Collapse all width: 20, tooltip: "", - handler: Ext.bind (this.collapseAll, this), + handler: Ext.bind (this.collapseAll, this, [], false), icon: Ametys.getPluginResourcesPrefix('cms') + '/img/tree/collapse-all.gif', cls: 'x-btn-text-icon' }, @@ -700,7 +689,12 @@ for (var i=0; i < paths.length; i++) { var path = paths[i].path; - this.expandPath (rootNode.getPath('name') + '/' + paths[i].path, 'name', null, Ext.bind (this._filterPaths, this, [paths, rootNode, node, paths[i].matchSynonyms || false], true)); + var options = { + field: 'name', + separator: null, + callback: Ext.bind (this._filterPaths, this, [paths, rootNode, node, paths[i].matchSynonyms || false], 2) + }; + this.expandPath (rootNode.getPath('name') + '/' + paths[i].path, options); } }, @@ -774,7 +768,7 @@ url: 'microthesaurus-nodes', reader: { type: 'xml', - root: 'Nodes', + rootProperty: 'Nodes', record: '> Node' } } @@ -789,12 +783,13 @@ * @private * Set the request parameters before loading the store. * @param {Ext.data.Store} store The store. - * @param {Ext.data.Operation} operation The Ext.data.Operation object that will be passed to the Proxy to load the Store. + * @param {Ext.data.operation.Operation} operation The Ext.data.Operation object that will be passed to the Proxy to load the Store. */ _onStoreBeforeLoad: function (store, operation) { - operation.params = operation.params || {}; - operation.params.hideCandidates = this._hideCandidates; + operation.setParams(Ext.apply(operation.getParams() || {}, { + hideCandidates: this._hideCandidates + })); }, /** @@ -853,61 +848,18 @@ { var selectedMT = microThesaurusId != null ? this._microThesaurusStore.getById(microThesaurusId) : this._microThesaurusStore.getAt(0); - var selectedMTId = selectedMT.get(this.getMTComboBox().valueField, true); - var selectedMTLabel = selectedMT.get(this.getMTComboBox().displayField, true); - - var rootNode = this.getRootNode(); - rootNode.set('text', selectedMTLabel); - rootNode.set('label', selectedMTLabel); - rootNode.set('name', ''); - rootNode.setId (selectedMTId); - rootNode.commit(); + this._setRootNode(selectedMT); - this.getMTComboBox().setValue(selectedMTId); + this.getMTComboBox().setValue(selectedMT.getId()); this.getSelectionModel().deselectAll(); - this.getStore().load({ - params: { - node: selectedMTId - }, - scope:this, - callback: function (records, operation, success) { - - this.getSelectionModel().select(this.getRootNode()); - - if (Ext.isFunction(callback)) - { - callback(); - } - } - }); + this.getSelectionModel().select(this.getRootNode()); } else { - if (Ext.isFunction(callback)) - { - callback(); - } + //we do not have some microthesaurus + this.getStore().setRoot(this._getInitRootConfig()); } - } - }); - } - else - { - var rootNode = this.getRootNode(); - rootNode.set('name', ''); - rootNode.setId (this._microthesaurusId); - rootNode.commit(); - - this.getStore().load({ - params: { - node: this._microthesaurusId - }, - scope:this, - callback: function (records, operation, success) { - - this.getSelectionModel().select(this.getRootNode()); - if (Ext.isFunction(callback)) { callback(); @@ -915,6 +867,21 @@ } }); } + else + { + this.getStore().setRoot(Ext.apply(this.getStore().getRoot(), { + name: '', + id: this._microthesaurusId + })); + + this.getSelectionModel().select(this.getRootNode()); + + if (Ext.isFunction(callback)) + { + callback(); + } + this.refreshNode(); + } }, @@ -950,15 +917,18 @@ node = selection.length > 0 ? selection[0] : null; // Workaround - Refresh selection in case node is not existing anymore (deleted by another user for example). - this.getSelectionModel().deselect(node); - this.getSelectionModel().select(node); + if (node != null) + { + this.getSelectionModel().deselect(node); + this.getSelectionModel().select(node); + } } else { node = this.getStore().getNodeById(id); } - if (node != null) + if (node != null && node.getId() != 'root') { // Set leaf to false, to allow children to be added during the load. Leaf will be set to true again if needed after the load. node.set('leaf', false); @@ -1014,29 +984,55 @@ * @private * Listener when a item is selected in the list. Reload the tree. * @param {Ext.form.field.ComboBox} combo The combox box - * @param {Array} records The selected records - * @param {Object} eOpts The options + * @param {Ext.data.Model} record The selected record + * @param {Object} eOpts The options object passed to Ext.util.Observable.addListener. */ - _microThesaurusComboSelect: function(combo, records, eOpts) + _microThesaurusComboSelect: function(combo, record, eOpts) { this.getSelectionModel().deselectAll(); this._clearSearchFilter(); - var rootNode = this.getRootNode(); - rootNode.setId (records[0].getId()); - rootNode.set ('text', records[0].get ('label')); - rootNode.set ('label', records[0].get ('label')); - rootNode.set('name', ''); - rootNode.commit(); + this._setRootNode(record); - this.getStore().load({ - params: { - node: records[0].getId() - }, - scope:this, - callback: function (records, operation, success) { - this.getSelectionModel().select(this.getRootNode()); - } + this.getSelectionModel().select(this.getRootNode()); + }, + + /** + * @private + * @return {Object} The config of the initial root node + */ + _getInitRootConfig: function() + { + return { + text: "", + leaf: true, + editable: false, + allowDrag: false, + allowDrop: false, + name: '', + type: 'microthesaurus', + iconCls: 'tree-icon-microthesaurus' + } + }, + + /** + * @private + * Set the root node to the given record + * @param {Ext.data.Model} record The selected record + */ + _setRootNode: function(record) + { + this.getStore().setRoot({ + id: record.getId(), + text: record.get ('label'), + editable: false, + allowDrag: false, + allowDrop: false, + expanded: true, + label: record.get ('label'), + name: '', + type: 'microthesaurus', + iconCls: 'tree-icon-microthesaurus' }); }, Index: main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/MicroThesaurusNodeGenerator.java =================================================================== --- main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/MicroThesaurusNodeGenerator.java (revision 32275) +++ main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/MicroThesaurusNodeGenerator.java (working copy) @@ -31,13 +31,13 @@ import org.xml.sax.SAXException; import org.ametys.cms.repository.Content; +import org.ametys.core.util.I18nUtils; +import org.ametys.core.util.I18nizableText; import org.ametys.plugins.repository.AmetysObject; import org.ametys.plugins.repository.AmetysObjectIterable; import org.ametys.plugins.repository.AmetysObjectResolver; import org.ametys.plugins.repository.TraversableAmetysObject; import org.ametys.plugins.thesaurus.content.ThesaurusItemContentType; -import org.ametys.runtime.util.I18nUtils; -import org.ametys.runtime.util.I18nizableText; /** * Generates a subtree of the resources explorer. Index: main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/ThesaurusDAO.java =================================================================== --- main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/ThesaurusDAO.java (revision 32275) +++ main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/ThesaurusDAO.java (working copy) @@ -50,6 +50,7 @@ import org.ametys.cms.repository.WorkflowAwareContentHelper; import org.ametys.cms.workflow.AbstractContentWorkflowComponent; import org.ametys.cms.workflow.ContentWorkflowHelper; +import org.ametys.core.ui.Callable; import org.ametys.plugins.repository.AmetysObject; import org.ametys.plugins.repository.AmetysObjectIterable; import org.ametys.plugins.repository.AmetysObjectResolver; @@ -65,7 +66,6 @@ import org.ametys.plugins.repository.metadata.RichText; import org.ametys.plugins.thesaurus.content.ThesaurusItemContentType; import org.ametys.plugins.thesaurus.workflow.CreateTermFunction; -import org.ametys.runtime.ui.Callable; import com.opensymphony.workflow.WorkflowException; Index: main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/clientsideelement/CompatibleTermMetadataFilter.java =================================================================== --- main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/clientsideelement/CompatibleTermMetadataFilter.java (revision 32275) +++ main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/clientsideelement/CompatibleTermMetadataFilter.java (working copy) @@ -29,7 +29,7 @@ import org.ametys.plugins.thesaurus.Thesaurus; import org.ametys.plugins.thesaurus.ThesaurusDAO; import org.ametys.plugins.thesaurus.content.ThesaurusItemContentType; -import org.ametys.runtime.util.I18nizableText; +import org.ametys.core.util.I18nizableText; /** * This extension is used when dragging thesaurus terms on content. Index: main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/clientsideelement/ThesaurusGallery.java =================================================================== --- main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/clientsideelement/ThesaurusGallery.java (revision 32275) +++ main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/clientsideelement/ThesaurusGallery.java (working copy) @@ -23,11 +23,11 @@ import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.framework.service.ServiceManager; -import org.ametys.cms.ui.SimpleMenu; +import org.ametys.core.ui.SimpleMenu; import org.ametys.plugins.repository.AmetysObjectIterable; import org.ametys.plugins.thesaurus.Thesaurus; import org.ametys.plugins.thesaurus.ThesaurusDAO; -import org.ametys.runtime.ui.Callable; +import org.ametys.core.ui.Callable; /** * This element creates a menu with one gallery item per thesaurus. Index: main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/parameter/TermsValidator.java =================================================================== --- main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/parameter/TermsValidator.java (revision 32275) +++ main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/parameter/TermsValidator.java (working copy) @@ -22,9 +22,9 @@ import org.ametys.cms.repository.Content; import org.ametys.plugins.repository.AmetysObjectResolver; import org.ametys.plugins.thesaurus.ThesaurusDAO; -import org.ametys.runtime.util.I18nizableText; -import org.ametys.runtime.util.parameter.DefaultValidator; -import org.ametys.runtime.util.parameter.Errors; +import org.ametys.core.util.I18nizableText; +import org.ametys.core.parameter.DefaultValidator; +import org.ametys.runtime.parameter.Errors; /** Index: main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/search/IndexedContentsGenerator.java =================================================================== --- main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/search/IndexedContentsGenerator.java (revision 32275) +++ main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/search/IndexedContentsGenerator.java (working copy) @@ -44,7 +44,7 @@ import org.ametys.cms.repository.Content; import org.ametys.plugins.thesaurus.ThesaurusDAO; import org.ametys.plugins.thesaurus.content.ThesaurusItemContentType; -import org.ametys.runtime.plugins.core.dispatcher.ServerCommHelper; +import org.ametys.core.util.ServerCommHelper; /** * SAX the contents indexed with one or more terms Index: main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/search/SelectTermSearchGenerator.java =================================================================== --- main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/search/SelectTermSearchGenerator.java (revision 32275) +++ main/plugin-thesaurus/src/org/ametys/plugins/thesaurus/search/SelectTermSearchGenerator.java (working copy) @@ -45,7 +45,7 @@ import org.ametys.plugins.repository.query.expression.StringExpression; import org.ametys.plugins.thesaurus.MicroThesaurus; import org.ametys.plugins.thesaurus.ThesaurusDAO; -import org.ametys.runtime.plugins.core.dispatcher.ServerCommHelper; +import org.ametys.core.util.ServerCommHelper; /** * Search generator used by 'edition.select-term' widget