/*
* 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 handles the access to page properties. See {@link Ametys.web.page.Page}
*/
Ext.define(
"Ametys.web.page.PageDAO",
{
singleton: true,
constructor: function(config)
{
/**
* @callable
* @param member Ametys.web.page.PageDAO
* @method createPage
* Create a page in sitemap
* This calls the method 'createPage' of the server DAO 'org.ametys.web.repository.page.PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.parentId The id of parent page or sitemap
* @param {String} parameters.title The page's title
* @param {String} parameters.longTitle The page's long title
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables({
role: "org.ametys.web.repository.page.PageDAO",
methodName: "createPage",
callback: {
handler: this._createPageCb
},
errorMessage: {
category: this.self.getName(),
msg: "{{i18n PLUGINS_WEB_DAOS_PAGE_CREATE_ERROR}}"
},
waitMessage: "{{i18n PLUGINS_WEB_DAOS_PAGE_CREATE_WAITING_MSG}}"
});
/**
* @callable
* @param member Ametys.web.page.PageDAO
* @method movePage
* Move a page in sitemap
* This calls the method 'movePage' of the server DAO 'org.ametys.web.repository.page.PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of page to move
* @param {String} parameters.parentId The id of parent target
* @param {Number} parameters.index The position in parent child nodes where page will be inserted. -1 means as the last child.
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables({
role: "org.ametys.web.repository.page.PageDAO",
methodName: "movePage",
callback: {
handler: this._movePageCb,
scope: this
},
waitMessage: true,
errorMessage: {
msg: "{{i18n PLUGINS_WEB_DAOS_PAGE_MOVE_ERROR}}",
category: Ext.getClassName(this)
}
});
/**
* @callable
* @param member Ametys.web.page.PageDAO
* @method renamePage
* Rename a page
* This calls the method 'renamePage' of the server DAO 'org.ametys.web.repository.page.PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of page to rename
* @param {String} parameters.title The page's title
* @param {String} parameters.longtitle The page's long title
* @param {Boolean} parameters.updatePath true if the path should be updated with the new title.
* @param {Boolean} parameters.alias true if an alias should be created.
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables({
role: "org.ametys.web.repository.page.PageDAO",
methodName: "renamePage",
callback: {
handler: this._renamePageCb
},
waitMessage: true,
errorMessage: {
msg: "{{i18n PLUGINS_WEB_DAOS_PAGE_RENAME_ERROR}}",
category: Ext.getClassName(this)
}
});
/**
* @callable
* @param member Ametys.web.page.PageDAO
* @method deletePage
* Delete a page
* This calls the method 'deletePage' of the server DAO 'org.ametys.web.repository.page.PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of page to delete
* @param {String[]} parameters.deleteOrphanContents true to delete the contents that belongs to the page or its sub-pages
* @param {Ametys.message.MessageTarget} parameters.pageTarget The page target
* @param {Ametys.message.MessageTarget[]} parameters.contentTargets The delete content's targets
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables({
role: "org.ametys.web.repository.page.PageDAO",
methodName: "deletePage",
callback: {
handler: this._deletePageCb
},
waitMessage: "{{i18n PLUGINS_WEB_DAOS_PAGE_DELETE_WAIT_MSG}}",
errorMessage: {
msg: "{{i18n PLUGINS_WEB_DAOS_PAGE_DELETE_ERROR}}",
category: Ext.getClassName(this)
},
localParamsIndex: 2
});
/**
* @callable
* @param member Ametys.web.page.PageDAO
* @method getDeleteablePageContents
* Get the deleteable contents that belong to the page
* This calls the method 'getDeleteablePageContents' of the server DAO 'org.ametys.web.repository.page.PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of page
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.result The resulting contents. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables({
role: "org.ametys.web.repository.page.PageDAO",
methodName: "getDeleteablePageContents",
waitMessage: true,
errorMessage: {
msg: "{{i18n PLUGINS_WEB_DAOS_PAGE_GET_UNREFERENCED_CONTENTS_ERROR}}",
category: Ext.getClassName(this)
}
});
/**
* @callable
* @param member Ametys.web.page.PageDAO
* @method setBlank
* Set page as blank page
* This calls the method 'setBlank' of the server DAO 'org.ametys.web.repository.page.PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.ids The ids of pages to set as blank pages
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables({
role: "org.ametys.web.repository.page.PageDAO",
methodName: "setBlank",
callback: {
handler: this._setBlankCb
},
waitMessage: true,
errorMessage: {
msg: "{{i18n PLUGINS_WEB_DAOS_PAGE_BLANKPAGE_ERROR}}",
category: Ext.getClassName(this)
}
});
/**
* @callable
* @param member Ametys.web.page.PageDAO
* @method setTemplate
* Affect a template to pages
* This calls the method 'setTemplate' of the server DAO 'org.ametys.web.repository.page.PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.ids The ids of concerned pages
* @param {String} parameters.templateName The name of template to affect
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables({
role: "org.ametys.web.repository.page.PageDAO",
methodName: "setTemplate",
callback: {
handler: this._setTemplateCb
},
waitMessage: "{{i18n PLUGINS_WEB_DAOS_PAGE_SET_TEMPLATE_WAITING_MSG}}",
errorMessage: {
msg: "{{i18n PLUGINS_WEB_DAOS_PAGE_SET_TEMPLATE_ERROR}}",
category: Ext.getClassName(this)
}
});
/**
* @callable
* @param member Ametys.web.page.PageDAO
* @method setLink
* Affect a template to pages
* This calls the method 'setLink' of the server DAO 'org.ametys.web.repository.page.PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.ids The ids of concerned pages
* @param {String} parameters.url The redirection url
* @param {String} parameters.urlType The redirection type: 'PAGE' or 'WEB'
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables({
role: "org.ametys.web.repository.page.PageDAO",
methodName: "setLink",
callback: {
handler: this._setLinkCb
},
waitMessage: true,
errorMessage: {
msg: "{{i18n PLUGINS_WEB_DAOS_PAGE_LINKPAGE_ERROR}}",
category: Ext.getClassName(this)
}
});
/**
* @callable
* @param member Ametys.web.page.PageDAO
* @method getAvailableServices
* Get the list of services that can be added to a page zone
* This calls the method 'getAvailableServices' of the server DAO 'org.ametys.web.repository.page.PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.pageId The id of page
* @param {String} parameters.zoneName The name of the zone
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables({
role: "org.ametys.web.repository.page.PageDAO",
methodName: "getAvailableServices",
waitMessage: true,
refreshing: true,
errorMessage: true
});
/**
* @callable
* @param member Ametys.web.page.PageDAO
* @method getServiceParameters
* Set a service to a page
* This calls the method 'getServiceParameters' of the server DAO 'org.ametys.web.repository.page.PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.zoneItemId The id of zone item
* @param {String} parameters.serviceId The id of service
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables({
role: "org.ametys.web.repository.page.PageDAO",
methodName: "getServiceParameters",
waitMessage: true,
errorMessage: {
msg: "{{i18n PLUGINS_WEB_DAOS_PAGE_CONFIGURESERVICE_ERROR}}",
category: Ext.getClassName(this)
}
});
/**
* @callable
* @param member Ametys.web.page.PageDAO
* @method setService
* Set a service to a page
* This calls the method 'setService' of the server DAO 'org.ametys.web.repository.page.PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.pageId The id of page
* @param {String} parameters.serviceId The id of service
* @param {String} parameters.zoneName the zone name
* @param {Object} parameters.parameters the services parameters
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables({
role: "org.ametys.web.repository.page.PageDAO",
methodName: "setService",
callback: {
handler: this._setServiceCb
},
waitMessage: true,
errorMessage: {
msg: "{{i18n PLUGINS_WEB_DAOS_PAGE_ADDSERVICEMENU_ERROR}}",
category: Ext.getClassName(this)
}
});
/**
* @callable
* @param member Ametys.web.page.PageDAO
* @method configureService
* Configure a service
* This calls the method 'configureService' of the server DAO 'org.ametys.web.repository.page.PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.serviceId The id of service
* @param {String} parameters.zoneItemId the id of zone item
* @param {Object} parameters.parameters the services parameters
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables({
role: "org.ametys.web.repository.page.PageDAO",
methodName: "configureService",
callback: {
handler: this._setServiceCb
},
waitMessage: true,
errorMessage: {
msg: "{{i18n PLUGINS_WEB_DAOS_PAGE_CONFIGURESERVICE_ERROR}}",
category: Ext.getClassName(this)
}
});
/**
* @callable
* @param member Ametys.web.page.PageDAO
* @method tag
* Set tags on REPLACE mode on pages and/or contents
* This calls the method 'tag' of the server DAO 'org.ametys.web.repository.page.PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String[]} parameters.pageIds The ids of pages to tag
* @param {String[]} parameters.contentIds the id of contents to tag
* @param {String[]} parameters.tagNames the tags' name
* @param {Object} parameters.contextualParameters the contextual parameters
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables({
role: "org.ametys.web.repository.page.PageDAO",
methodName: "tag",
callback: {
handler: this._tagCb
},
waitMessage: true,
errorMessage: {
errorMessage: "{{i18n PLUGINS_WEB_DAOS_PAGE_TAG_ERROR}}",
category: Ext.getClassName(this)
}
});
/**
* @callable
* @param member Ametys.web.page.PageDAO
* @method setVisibility
* Set the visibility of pages
* This calls the method 'setVisibility' of the server DAO 'org.ametys.web.repository.page.PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String[]} parameters.pageIds The ids of pages to tag
* @param {Boolean} parameters.visibility The visibility
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.returnedValue The value return from the server. Null on error (please note that when an error occured, the callback may not be called depending on the value of errorMessage).
* @param {Object} callback.returnedValue.allright-pages The pages successfully updated
* @param {Object} callback.returnedValue.nomodifiable-pages The pages not updated because they are not modifiable
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables({
role: "org.ametys.web.repository.page.PageDAO",
methodName: "setVisibility",
callback: {
handler: this._setVisibilityCb
},
waitMessage: true,
errorMessage: {
errorMessage: "{{i18n PLUGINS_WEB_DAOS_PAGE_SET_VISIBILITY_ERROR}}",
category: Ext.getClassName(this)
}
});
/**
* @callable
* @param member Ametys.web.page.PageDAO
* @method hasRight
* Check the current user right
* This calls the method 'hasRight' of the server DAO 'org.ametys.web.repository.page.PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of page
* @param {String} parameters.right The id of right to check
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.hasRight true if the user has right, false otherwise.
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables({
role: "org.ametys.web.repository.page.PageDAO",
methodName: "hasRight",
waitMessage: false,
errorMessage: {
msg: "{{i18n PLUGINS_WEB_DAOS_PAGE_MOVE_ERROR}}",
category: Ext.getClassName(this)
}
});
/**
* @callable
* @param member Ametys.web.page.PageDAO
* @method getPageParents
* Get the page parents
* This calls the method 'getPageParents' of the server DAO 'org.ametys.web.repository.page.PageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of page
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {Object} callback.parents list of parents.
* @param {Object} callback.arguments Other arguments specified in option.arguments
* @param {Object} [options] Advanced options for the call.
* @param {Boolean/String/Object} [options.errorMessage] Display an error message. See Ametys.data.ServerComm#callMethod errorMessage.
* @param {Boolean/String/Object} [options.waitMessage] Display a waiting message. See Ametys.data.ServerComm#callMethod waitMessage.
* @param {Number} [options.scope] This parameter is the scope used to call the callback. Moreover is the given class is a mixin of Ametys.data.ServerCaller, its methods Ametys.data.ServerCaller#beforeServerCall and Ametys.data.ServerCaller#afterServerCall will be used so see their documentation to look for additional options (such a refreshing on Ametys.ribbon.element.ui.ButtonController#beforeServerCall).
* @param {Number} [options.priority] The message priority. See Ametys.data.ServerComm#callMethod for more information on the priority. PRIORITY_SYNCHRONOUS cannot be used here.
* @param {String} [options.cancelCode] Cancel similar unachieved read operations. See Ametys.data.ServerComm#callMethod cancelCode.
* @param {Object} [options.arguments] Additional arguments set in the callback.arguments parameter.
* @param {Boolean} [options.ignoreCallbackOnError] If the server throws an exception, should the callback beeing called with a null parameter. See Ametys.data.ServerComm#callMethod ignoreOnError.
*/
this.addCallables({
role: "org.ametys.web.repository.page.PageDAO",
methodName: "getPageParents",
waitMessage: false,
errorMessage: {
msg: "{{i18n PLUGINS_WEB_DAOS_PAGE_MOVE_ERROR}}",
category: Ext.getClassName(this)
}
});
},
/**
* Retrieve a page by its id
* @param {String} id The page identifier. Cannot be null.
* @param {Function} callback The callback function called when the page is retrieved. Can be null for synchronous mode (not recommended!). Parameters are
* @param {Ametys.web.page.Page} callback.page The page retrieved. Can be null if page does not exist.
* @param {String} [workspaceName] The JCR workspace name
* @param {Object} [errorMessage] The error message
* @param {String} [zoneName] A zone name to limit informations to that zone for performance purposes
* @param {String} [zoneItemId] A zoneitem id to limit informations to that zoneitem for performance purposes
* @param {String} [cancelCode] The code to cancel request (see Ametys.data.ServerComm#callMethod)
* @return {Ametys.web.page.Page} The page retrieved if no callback function is specified or null otherwise.
*/
getPage: function (id, callback, workspaceName, errorMessage, zoneName, zoneItemId, cancelCode)
{
if (Ext.isEmpty(id))
{
callback(null);
return;
}
this._sendRequest ([id], zoneName, zoneItemId, Ext.bind(this._getPageCb, this, [callback], 1), workspaceName, errorMessage, cancelCode);
},
/**
* @private
* Callback function called after #getPage is processed
* @param {Ametys.web.page.Page[]} pages The pages retrieved
* @param {Function} callback The callback function called
*/
_getPageCb: function (pages, callback)
{
callback((pages.length == 0) ? null : pages[0]);
},
/**
* Retrieve pages by their ids
* @param {String[]} ids The pages identifiers. Cannot be null.
* @param {Function} callback The callback function called when the page is retrieved. Can be null for synchronous mode (not recommended!). Parameters are
* @param {Ametys.web.page.Page} callback.page The page retrieved. Can be null if page does not exist.
* @param {String} [workspaceName] The JCR workspace name
* @param {Object} [errorMessage] The error message
* @param {String} [zoneName] A zone name to limit informations to that zone for performance purposes
* @param {String} [zoneItemId] A zoneitem id to limit informations to that zoneitem for performance purposes
* @param {String} [cancelCode] The code to cancel request (see Ametys.data.ServerComm#callMethod)
* @return {Ametys.web.page.Page} The page retrieved if no callback function is specified or null otherwise.
*/
getPages: function (ids, callback, workspaceName, errorMessage, zoneName, zoneItemId, cancelCode)
{
if (Ext.isEmpty(ids))
{
callback([]);
return;
}
this._sendRequest (ids, zoneName, zoneItemId, Ext.bind(this._getPagesCb, this, [callback], 1), workspaceName, errorMessage, cancelCode);
},
/**
* @private
* Callback function called after #getPages is processed
* @param {Ametys.web.page.Page[]} pages The pages retrieved
* @param {Function} callback The callback function called
*/
_getPagesCb: function (pages, callback)
{
callback(pages);
},
/**
* @private
* Send request to server to retrieved pages
* @param {String[]} ids The id of pages to retrieve
* @param {String} [zoneName] A zone name to limit informations to that zone for performance purposes
* @param {String} [zoneItemId] A zoneitem id to limit informations to that zoneitem for performance purposes
* @param {Function} callback The callback function to be called after server process
* @param {String} [workspaceName] The JCR workspace name
* @param {Object} [errorMessage] The error message to use
* @param {String} [cancelCode] The code to cancel request (see Ametys.data.ServerComm#callMethod)
*/
_sendRequest: function (ids, zoneName, zoneItemId, callback, workspaceName, errorMessage, cancelCode)
{
if (errorMessage === undefined)
{
errorMessage = {
category: this.self.getName(),
msg: "{{i18n PLUGINS_WEB_DAOS_PAGE_ERROR}}"
};
}
Ametys.data.ServerComm.callMethod({
role: "org.ametys.web.repository.page.PageDAO",
methodName: "getPagesInfos",
parameters: [ids, zoneName, zoneItemId],
callback: {
scope: this,
handler: this._getPagesCB,
arguments: [callback, errorMessage === false]
},
errorMessage: errorMessage,
cancelCode: cancelCode
});
},
/**
* @private
* Callback function called after #_sendRequest is processed
* @param {Object} result The server response
* @param {Array} arguments The callback arguments.
*/
_getPagesCB: function (result, arguments)
{
var pages = [];
var pagesCfg = result.pages;
if (this.getLogger().isDebugEnabled())
{
this.getLogger().debug(pagesCfg.length + " page(s) get from server and " + result.pagesNotFound.length + " page(s) where not found");
}
for (var i=0; i < pagesCfg.length; i++)
{
pages.push(Ext.create ('Ametys.web.page.Page', pagesCfg[i]));
}
var pagesNotFound = result.pagesNotFound;
if (pagesNotFound.length > 0
&& !arguments[1]) // skip error message
{
Ametys.log.ErrorDialog.display({
title: "{{i18n PLUGINS_WEB_DAOS_PAGE_NOT_FOUND}}",
text: "{{i18n PLUGINS_WEB_DAOS_PAGE_NOT_FOUND_HINT}}",
details: pagesNotFound.join(", "),
category: "Ametys.web.page.PageDAO"
});
}
if (typeof arguments[0] == 'function')
{
arguments[0] (pages);
}
},
/**
* @private
* Callback function called after page was created
* @param {Object} response The server result
* @param {Object} response.id The id of created page
* @param {Object} response.parentId The id of parent page or sitemap
* @param {Object} args The callback arguments
*/
_createPageCb: function (response, args)
{
Ametys.web.page.PageDAO.getPage (response.id, Ext.bind(this._finalizeCreation, this));
},
/**
* Finalize page creation process
* @param {Ametys.web.page.Page} page The created page
*/
_finalizeCreation: function (page)
{
// Notify page creation
Ametys.notify({
type: 'info',
iconGlyph: 'ametysicon-website38',
title: "{{i18n PLUGINS_WEB_NOTIFICATION_CREATE_PAGE_TITLE}}",
description: Ext.String.format("{{i18n PLUGINS_WEB_NOTIFICATION_CREATE_PAGE_DESCRIPTION}}", Ext.String.escapeHtml(page.getTitle())),
action: Ext.bind(Ametys.tool.ToolsManager.openTool, Ametys.tool.ToolsManager, ['uitool-page', {id: page.getId()}], false)
});
Ext.create('Ametys.message.Message', {
type: Ametys.message.Message.CREATED,
targets: [{
id: Ametys.message.MessageTarget.PAGE,
parameters: {
pages: [page]
}
}]
});
},
/**
* Lock the page
* @param {String} id the id of page
* @param {String} pageTarget the page target
* @param {Function} [callback] Callback function to invoke after locking the page
*/
lockPage: function(id, pageTarget, callback)
{
var page = Ext.create("Ametys.web.page.Page", {
id: id,
locked: false,
messageTarget: pageTarget
});
page.lock(callback);
},
/**
* Unlock the page
* @param {String} id the id of page
* @param {String} pageTarget the page target
* @param {Function} [callback] Callback function to invoke after unlocking the page
*/
unlockPage: function(id, pageTarget, callback)
{
var page = Ext.create("Ametys.web.page.Page", {
id: id,
locked: true,
messageTarget: pageTarget
});
page.unlock(callback);
},
// ----------------------------------------------------------------------------------
/**
* @private
* Callback function after moving
* @param {Object} response The serveur response
* @param {Object} args The callback arguments
*/
_movePageCb: function (response, args)
{
if (response.id)
{
Ext.create('Ametys.message.Message', {
type: Ametys.message.Message.MOVED,
targets: [{
id: Ametys.message.MessageTarget.PAGE,
parameters: {
ids: [response.id]
}
}]
});
}
},
/**
* @private
* Callback function called after page was renamed
* @param {Object} response The server result
* @param {Object} args The callback arguments
*/
_renamePageCb: function (response, args)
{
if (response['invalid-name'])
{
Ametys.Msg.show({
title: "{{i18n PLUGINS_WEB_RENAMEPAGE_CAPTION}}",
msg: "{{i18n PLUGINS_WEB_DAOS_PAGE_RENAME_INVALID_NAME}}",
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.ERROR
});
return;
}
Ext.create('Ametys.message.Message', {
type: Ametys.message.Message.MODIFIED,
targets: [{
id: Ametys.message.MessageTarget.PAGE,
parameters: {
ids: [response.id]
}
}]
});
},
/**
* @private
* Callback function called after page was removed
* @param {Object} response The server result
* @param {Object} args The callback arguments
* @param {Object[]} params The callback parameters (server-side and client-side) :
* @param {String} params.id The id of deleted page
* @param {Boolean} params.deleteBelongingContents true to delete the content that belong to the deleted pages
* @param {Ametys.message.MessageTarget} params.pageTarget The deleted page's targets
* @param {Ametys.message.MessageTarget} params.contentTarget The deleted content's targets
*/
_deletePageCb: function (response, args, params)
{
// Notify page creation
Ametys.notify({
type: 'info',
iconGlyph: 'ametysicon-website38',
title: "{{i18n PLUGINS_WEB_NOTIFICATION_DELETE_PAGE_TITLE}}",
description: Ext.String.format("{{i18n PLUGINS_WEB_NOTIFICATION_DELETE_PAGE_DESCRIPTION}}", Ext.String.escapeHtml(params[2].getParameters().title))
});
Ext.create('Ametys.message.Message', {
type: Ametys.message.Message.DELETED,
targets: params[2],
parameters : {
trashed: response.trashed || false
}
});
if (params[3] && params[3].length > 0)
{
Ametys.cms.content.ContentDAO._trashContentsCb(response, {targets: params[3]});
}
},
/**
* Callback function after updating pages
* @param {Object} response The server response
* @param {Object} args The callback arguments
*/
_setLinkCb: function (response, args)
{
var ids = response["allright-pages"] || [];
if (ids.length)
{
Ext.create('Ametys.message.Message', {
type: Ametys.message.Message.MODIFIED, // FIXME TYPE_CHANGED ?
targets: [{
id: Ametys.message.MessageTarget.PAGE,
parameters: {
ids: ids,
'zone-name': null
}
}]
});
}
this._handleTypeErrors(response, "{{i18n PLUGINS_WEB_PAGE_LINKPAGE_ERRORTITLE}}");
},
/**
* Callback function after updating pages
* @param {Object} response The server response
* @param {Object} args The callback arguments
*/
_setBlankCb: function (response, args)
{
var ids = response["allright-pages"] || [];
if (ids.length)
{
Ext.create('Ametys.message.Message', {
type: Ametys.message.Message.MODIFIED, // FIXME TYPE_CHANGED ?
targets: [{
id: Ametys.message.MessageTarget.PAGE,
parameters: {
ids: ids,
'zone-name': null
}
}]
});
}
this._handleTypeErrors(response, "{{i18n PLUGINS_WEB_DAOS_PAGE_BLANKPAGE_ERRORTITLE}}");
},
/**
* Callback function after updating pages
* @param {Object} response The server response
* @param {Object} args The callback arguments
*/
_setTemplateCb: function (response, args)
{
var ids = response["allright-pages"] || [];
if (ids.length)
{
Ext.create('Ametys.message.Message', {
type: Ametys.message.Message.MODIFIED, // FIXME TYPE_CHANGED + templateChange ?
targets: [{
id: Ametys.message.MessageTarget.PAGE,
parameters: {
ids: ids,
'zone-name': response.zonename
}
}]
});
}
this._handleTypeErrors(response, "{{i18n PLUGINS_WEB_DAOS_PAGE_SET_TEMPLATE_ERROR_TITLE}}");
},
/**
* @private
* Show error messages if needed when modifying the type of the page
* @param {Object} response the server response
* @param {String} errorTitle the error title
*/
_handleTypeErrors: function (response, errorTitle)
{
var errorMsg = "";
var pagesInError = response["error-pages"] || []
if (pagesInError.length)
{
errorMsg += "{{i18n PLUGINS_WEB_DAOS_PAGE_MODIFY_TYPE_PAGE_ERROR}}";
errorMsg += Ext.Array.map(pagesInError, p => "<strong>" + p.title + "</strong>").join(", ");
}
var noRightPages = response["noright-pages"] || [];
if (noRightPages.length)
{
if (errorMsg)
{
errorMsg += "<br/><br/>";
}
errorMsg += "{{i18n PLUGINS_WEB_DAOS_PAGE_MODIFY_TYPE_NORIGHT_ERROR}}";
errorMsg += Ext.Array.map(noRightPages, p => "<strong>" + p.title + "</strong>").join(", ");
}
var noModifiablePages = response["nomodifiable-pages"] || [];
if (noModifiablePages.length)
{
if (errorMsg)
{
errorMsg += "<br/><br/>";
}
errorMsg += "{{i18n PLUGINS_WEB_DAOS_PAGE_MODIFY_TYPE_NOMODIFIABLE_ERROR}}";
errorMsg += Ext.Array.map(noModifiablePages, p => "<strong>" + p.title + "</strong>").join(", ");
}
var lockedPage = response["locked-pages"] || [];
if (lockedPage.length)
{
if (errorMsg)
{
errorMsg += "<br/><br/>";
}
errorMsg += "{{i18n PLUGINS_WEB_DAOS_PAGE_MODIFY_TYPE_LOCKED_ERROR}}";
errorMsg += Ext.Array.map(lockedPage, p => "<strong>" + p.title + "</strong>").join(", ");
}
if (errorMsg)
{
Ametys.Msg.show({
title: errorTitle,
msg: errorMsg,
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.ERROR
});
}
},
/**
* Callback function after updating pages
* @param {Object} response The server response
* @param {Object} args The callback arguments
*/
_setServiceCb: function (response, args)
{
var errors = response.error;
if (!Ext.isEmpty(errors))
{
var details = "";
for (var error in errors)
{
details += error + ": " + errors[error].join("; ") + "\n";
}
Ametys.log.ErrorDialog.display({
title: "{{i18n PLUGINS_WEB_DAOS_PAGE_CONFIGURESERVICE_FAILED_TITLE}}",
text: "{{i18n PLUGINS_WEB_DAOS_PAGE_CONFIGURESERVICE_FAILED_DESC}}",
details: details,
category: this.self.getName()
});
}
else
{
Ext.create('Ametys.message.Message', {
type: Ametys.message.Message.MODIFIED,
parameters: {"creation": "service"},
targets: [{
id: Ametys.message.MessageTarget.PAGE,
parameters: {
ids: [response.id],
'zone-name': null,
'zoneitem-id': response['zoneitem-id']
}
}]
});
}
},
/**
* Callback function after setting tags
* @param {Object} response The server response
* @param {Object} args The callback arguments
*/
_tagCb: function (response, args)
{
var pages = response["allright-pages"];
if (pages != null && pages.length > 0)
{
var ids = [];
for (var i = 0; i < pages.length; i++)
{
ids.push(pages[i].id);
}
Ext.create("Ametys.message.Message", {
type: Ametys.message.Message.MODIFIED,
targets: {
id: Ametys.message.MessageTarget.PAGE,
parameters: {
ids: ids
}
}
});
}
var contents = response["allright-contents"];
if (contents != null && contents.length > 0)
{
var ids = [];
for (var i = 0; i < contents.length; i++)
{
ids.push(contents[i].id);
}
Ext.create("Ametys.message.Message", {
type: Ametys.message.Message.MODIFIED,
targets: {
id: Ametys.message.MessageTarget.CONTENT,
parameters: {
ids: ids
}
}
});
}
this._handleTagErrors(response, "{{i18n PLUGINS_WEB_DAOS_PAGE_TAG_ERROR}}");
},
/**
* @private
* Show error messages if needed when modifying the tag of the page
* @param {Object} response the server response
* @param {String} errorTitle the error title
*/
_handleTagErrors: function (response, errorTitle)
{
var errorMsg = [];
var invalidTags = response["invalid-tags"] || [];
if (invalidTags.length == 1)
{
errorMsg = errorMsg.concat("{{i18n PLUGINS_WEB_DAOS_PAGE_TAG_INVALID_ERROR}}" + "<strong>" + noModifPages[0].title + "</strong>");
}
else if (invalidTags.length > 1)
{
errorMsg = errorMsg.concat("{{i18n PLUGINS_WEB_DAOS_PAGE_TAG_INVALID_ERROR_MULTIPLE}}" + Ext.Array.map(invalidTags, t => "<strong>" + t + "</strong>").join(", "));
}
var noModifPages = response["nomodifiable-pages"] || [];
if (noModifPages.length == 1)
{
errorMsg = errorMsg.concat("{{i18n PLUGINS_WEB_DAOS_PAGE_TAG_PAGE_NOMODIFIABLE_ERROR}}" + "<strong>" + noModifPages[0].title + "</strong>");
}
else if (noModifPages.length > 1)
{
errorMsg = errorMsg.concat("{{i18n PLUGINS_WEB_DAOS_PAGE_TAG_PAGE_NOMODIFIABLE_ERROR_MULTIPLE}}" + Ext.Array.map(noModifPages, p => "<strong>" + p.title + "</strong>").join(", "));
}
var noRightPages = response["noright-pages"] || [];
if (noRightPages.length == 1)
{
errorMsg = errorMsg.concat("{{i18n PLUGINS_WEB_DAOS_PAGE_TAG_PAGE_NORIGHT_ERROR}}" + "<strong>" + noRightPages[0].title + "</strong>");
}
else if (noRightPages.length > 1)
{
errorMsg = errorMsg.concat("{{i18n PLUGINS_WEB_DAOS_PAGE_TAG_PAGE_NORIGHT_ERROR_MULTIPLE}}" + Ext.Array.map(noRightPages, p => "<strong>" + p.title + "</strong>").join(", "));
}
var noTagContents = response["notaggable-contents"] || [];
if (noTagContents.length == 1)
{
errorMsg = errorMsg.concat("{{i18n PLUGINS_WEB_DAOS_PAGE_TAG_CONTENT_NOTAGGABLE_ERROR}}" + "<strong>" + noTagContents[0].title + "</strong>");
}
else if (noTagContents.length > 1)
{
errorMsg = errorMsg.concat("{{i18n PLUGINS_WEB_DAOS_PAGE_TAG_CONTENT_NOTAGGABLE_ERROR_MULTIPLE}}" + Ext.Array.map(noTagContents, c => "<strong>" + c.title + "</strong>").join(", "));
}
var noRightContents = response["noright-contents"] || [];
if (noRightContents.length == 1)
{
errorMsg = errorMsg.concat("{{i18n PLUGINS_WEB_DAOS_PAGE_TAG_CONTENT_NORIGHT_ERROR}}" + "<strong>" + noRightContents[0].title + "</strong>");
}
if (noRightContents.length > 1)
{
errorMsg = errorMsg.concat("{{i18n PLUGINS_WEB_DAOS_PAGE_TAG_CONTENT_NORIGHT_ERROR_MULTIPLE}}" + Ext.Array.map(noRightContents, c => "<strong>" + c.title + "</strong>").join(", "));
}
var lockedContents = response["locked-contents"] || [];
if (lockedContents.length == 1)
{
errorMsg = errorMsg.concat("{{i18n PLUGINS_WEB_DAOS_PAGE_TAG_CONTENT_LOCKED_ERROR}}" + "<strong>" + lockedContents[0].title + "</strong>");
}
if (lockedContents.length > 1)
{
errorMsg = errorMsg.concat("{{i18n PLUGINS_WEB_DAOS_PAGE_TAG_CONTENT_LOCKED_ERROR_MULTIPLE}}" + Ext.Array.map(lockedContents, c => "<strong>" + c.title + "</strong>").join(", "));
}
if (errorMsg.length)
{
Ametys.Msg.show({
title: errorTitle,
msg: errorMsg.join("<br/><br/>"),
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.ERROR
});
}
},
/**
* Callback function after setting tags
* @param {Object} response The server response
* @param {Object} args The callback arguments
*/
_setVisibilityCb: function (response, args)
{
var pages = response["allright-pages"] || [];
if (pages.length)
{
Ext.create("Ametys.message.Message", {
type: Ametys.message.Message.MODIFIED,
targets: {
id: Ametys.message.MessageTarget.PAGE,
parameters: {
ids: Ext.Array.map(pages, p => p.id)
}
}
});
}
this._showError(
response["noright-pages"] || response["locked-pages"] || [],
"{{i18n PLUGINS_WEB_PAGE_VISIBILITY_LABEL}}",
response["noright-pages"] ? "{{i18n PLUGINS_WEB_DAOS_PAGE_SET_VISIBILITY_NORIGHT_ERROR}}" : "{{i18n PLUGINS_WEB_DAOS_PAGE_SET_VISIBILITY_LOCKED_ERROR}}");
},
/**
* @private
* @param {Object[]} pagesInError pages in errors
* @param {String} errorTitle title of the error
* @param {String} errorMsg error message
*/
_showError: function (pagesInError, errorTitle, errorMsg)
{
if (pagesInError.length)
{
var msg = errorMsg;
msg += Ext.Array.map(pagesInError, p => p.title).join(", ");
Ametys.Msg.show({
title: errorTitle,
msg: msg,
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.ERROR
});
}
}
}
);