/*
* Copyright 2021 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.
*/
/**
* The forms page DAO
*/
Ext.define('Ametys.plugins.forms.dao.FormPageDAO', {
singleton: true,
constructor: function()
{
/**
* @callable
* @member Ametys.plugins.forms.dao.FormPageDAO
* @method createPage
* Creates a form.
* This calls the method 'createPage' of the server DAO 'FormPageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.title The title
* @param {String} parameters.siteName The site name
* @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.plugins.forms.dao.FormPageDAO",
methodName: "createPage",
callback: {
handler: this._createPageCb
},
errorMessage: {
msg: "{{i18n PLUGINS_FORMS_CREATE_PAGE_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.plugins.forms.dao.FormPageDAO
* @method getPageProperties
* Get the page's properties
* This calls the method 'getPageProperties' of the server DAO 'FormPageDAO'.
* @param {String} pageId the pageId
* @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.plugins.forms.dao.FormPageDAO",
methodName: "getPageProperties",
convertor: this._convertPageProperties,
errorMessage: {
msg: "{{i18n DAOS_FORM_REQUEST_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.plugins.forms.dao.FormPageDAO
* @method renamePage
* Rename a page.
* This calls the method 'renamePage' of the server DAO 'FormPageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of the page to rename
* @param {String} parameters.newName The new name for the page
* @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.plugins.forms.dao.FormPageDAO",
methodName: "renamePage",
callback: {
handler: this._renamePageCb
},
errorMessage: {
msg: "{{i18n PLUGINS_FORMS_RENAME_PAGE_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.plugins.forms.dao.FormPageDAO
* @method deletePage
* Deletes a page.
* This calls the method 'deletePage' of the server DAO 'FormPageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of the page to delete
* @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.plugins.forms.dao.FormPageDAO",
methodName: "deletePage",
callback: {
handler: this._deletePageCb,
scope: this
},
errorMessage: {
msg: "{{i18n PLUGINS_FORMS_DELETE_PAGE_ERROR}}",
category: Ext.getClassName(this)
},
localParamsIndex: 1
}
);
/**
* @callable
* @member Ametys.plugins.forms.dao.FormPageDAO
* @method copyPage
* Copies and pastes a form page.
* This calls the method 'copyPage' of the server DAO 'FormPageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.formId The id of the form, target of the copy
* @param {String} parameters.pageId The id of the page to copy
* @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.plugins.forms.dao.FormPageDAO",
methodName: "copyPage",
callback: {
handler: this._copyPageCb
},
errorMessage: {
msg: "{{i18n PLUGINS_FORMS_COPY_PAGE_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.plugins.forms.dao.FormPageDAO
* @method getIdsOfPath
* Gets the ids of the path elements of a form element, i.e. the parent ids.
* For instance, if the page path is 'a/b/c', then the result list will be ["id-of-a", "id-of-b", "id-of-c"]
* This calls the method 'getIdsOfPath' of the server DAO 'FormPageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.formId The id of the form
* @param {Function} callback The function to call when the java process is over. Use options.scope for the scope.
* @param {String[]} 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.plugins.forms.dao.FormPageDAO",
methodName: "getIdsOfPath",
callback: {
handler: Ext.emptyFn
},
waitMessage: false,
errorMessage: {
msg: "{{i18n PLUGINS_FORMS_GET_PATH_PAGE_REQUEST_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.plugins.forms.dao.FormPageDAO
* @method moveObject
* Moves an element of the form.
* This calls the method 'moveObject' of the server DAO 'FormPageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of the element to move.
* @param {String} parameters.oldParent The id of the element's parent.
* @param {String} parameters.newParent The id of the new element's parent.
* @param {Number} parameters.index The index where to move. null to place the element at the end.
* @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.plugins.forms.dao.FormPageDAO",
methodName: "moveObject",
callback: {
handler: this._moveObjectCb
},
errorMessage: {
msg: "{{i18n PLUGINS_FORMS_TOOL_MOVE_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.plugins.forms.dao.FormPageDAO
* @method getBranches
* Gets the branches for a form page.
* This calls the method 'getBranches' of the server DAO 'FormPageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of the page
* @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.plugins.forms.dao.FormPageDAO",
methodName: "getBranches",
callback: {
handler: Ext.emptyFn
},
errorMessage: {
msg: "{{i18n PLUGINS_FORMS_BRANCHES_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.plugins.forms.dao.FormPageDAO
* @method getRule
* Gets the rule for a form page.
* This calls the method 'getRule' of the server DAO 'FormPageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of the page
* @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.plugins.forms.dao.FormPageDAO",
methodName: "getRule",
callback: {
handler: Ext.emptyFn
},
errorMessage: {
msg: "{{i18n PLUGINS_FORMS_BRANCHES_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.plugins.forms.dao.FormPageDAO
* @method addRule
* Adds a a new rule to a page.
* This calls the method 'addRule' of the server DAO 'FormPageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of the page
* @param {String} parameters.rule The rule type
* @param {String} parameters.page The page to jump or skip
* @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.plugins.forms.dao.FormPageDAO",
methodName: "addRule",
callback: {
handler: Ext.emptyFn
},
errorMessage: {
msg: "{{i18n PLUGINS_FORMS_ADD_RULE_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.plugins.forms.dao.FormPageDAO
* @method deleteRule
* Deletes a rule to a page
* This calls the method 'deleteRule' of the server DAO 'FormPageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of the page
* @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.plugins.forms.dao.FormPageDAO",
methodName: "deleteRule",
callback: {
handler: Ext.emptyFn
},
errorMessage: {
msg: "{{i18n PLUGINS_FORMS_DELETE_RULE_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.plugins.forms.dao.FormPageDAO
* @method getChildren
* Gets the children pages of a form.
* This calls the method 'getChildPages' of the server DAO 'FormPageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of the form
* @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.plugins.forms.dao.FormPageDAO",
methodName: "getChildPages",
callback: {
handler: Ext.emptyFn
},
errorMessage: {
msg: "{{i18n PLUGINS_FORMS_TOOL_ERROR}}",
category: Ext.getClassName(this)
}
}
);
/**
* @callable
* @member Ametys.plugins.forms.dao.FormPageDAO
* @method isLastPage
* Determines if a page is the last of form's pages.
* This calls the method 'isLastPage' of the server DAO 'FormPageDAO'.
* @param {Object[]} parameters The parameters to transmit to the server method
* @param {String} parameters.id The id of the page to test
* @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.plugins.forms.dao.FormPageDAO",
methodName: "isLastPage",
callback: {
handler: Ext.emptyFn
},
errorMessage: {
msg: "{{i18n PLUGINS_FORMS_TOOL_ERROR}}",
category: Ext.getClassName(this)
}
}
);
},
/**
* Get page properties
* @param {String[]} ids The page ids
* @param {Function} callback The callback
*/
getPageProperties: function(ids, callback)
{
Ametys.data.ServerComm.callMethod({
role: "org.ametys.plugins.forms.dao.FormPageDAO",
methodName: "getPageProperties",
parameters: [ids[0]], //No multiselection
callback: {
scope: this,
handler: Ext.bind(this._getPageCB, this, [callback], 1),
},
waitMessage: false,
errorMessage: {
msg: "{{i18n DAOS_FORM_REQUEST_ERROR}}",
category: Ext.getClassName(this)
}
});
},
/**
* Callback function called after {@link #createPage} has been processed.
* @param {Object} response The server response
* @private
*/
_createPageCb: function(response, args, params)
{
Ext.create("Ametys.message.Message", {
type: Ametys.message.Message.CREATED,
targets: {
id: Ametys.message.MessageTarget.FORM_PAGE,
parameters: {
id: response.id,
formId : params[0].formId
}
}
});
},
/**
* Callback function called after {@link #renamePage} has been processed.
* @param {Object} response The server response
* @private
*/
_renamePageCb: function(response)
{
if (response.message == 'cannot-rename')
{
Ametys.Msg.show({
title: "{{i18n PLUGINS_FORMS_CANNOT_RENAME_PAGE_TITLE}}",
msg: "{{i18n PLUGINS_FORMS_CANNOT_RENAME_PAGE_MSG}}",
buttons: Ext.Msg.OK,
icon: Ext.Msg.WARNING
});
}
else
{
var pageId = response.id,
pageNewName = response.newName;
Ext.create("Ametys.message.Message", {
type: Ametys.message.Message.MODIFIED,
targets: {
id: Ametys.message.MessageTarget.FORM_PAGE,
parameters: {
id: pageId,
name: pageNewName,
formId: response.formId
}
}
});
}
},
/**
* Callback function called after {@link #deletePage} has been processed.
* @param {Object} response The server response
* @param {Object[]} params The parameters (server-side and client-side)
* @param {Object} params[0] the page's id
* @param {Object} params[1] the target to delete
* @private
*/
_deletePageCb: function(response, args, params)
{
Ext.create("Ametys.message.Message", {
type: Ametys.message.Message.DELETED,
targets: params[1]
});
},
/**
* Callback function called after {@link #copyPage} has been processed.
* @param {Object} response The text response provided by the {@link Ametys.data.ServerComm}
* @private
*/
_copyPageCb: function(response)
{
Ext.create("Ametys.message.Message", {
type: Ametys.message.Message.CREATED,
targets: {
id: Ametys.message.MessageTarget.FORM_PAGE,
parameters: {
id: response.id,
formId: response.formId
}
}
});
},
/**
* Callback function called after {@link #moveObject} has been processed.
* @param {Object} response The text response provided by the {@link Ametys.data.ServerComm}
* @private
*/
_moveObjectCb: function(response)
{
var targetId, parameters;
if (response.type == 'page')
{
targetId = Ametys.message.MessageTarget.FORM_PAGE;
parameters = {
id: response.id,
formId: response.newParentId
};
}
else if (response.type == 'question')
{
targetId = Ametys.message.MessageTarget.FORM_QUESTION;
parameters = {
id: response.id,
type: response.questionType,
pageId: response.newParentId,
formId: response.newFormId
};
}
Ext.create("Ametys.message.Message", {
type: Ametys.message.Message.MOVED,
targets: {
id: targetId,
parameters: parameters
}
});
},
/**
* @private
* Convert function called after #getPageProperties is processed
* @param {Object} pageProperties The server response
*/
_convertPageProperties: function (pageProperties)
{
return Ext.create ('Ametys.plugins.forms.Page', pageProperties);
}
});