Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"version":3,"file":"policyactions.min.js","sources":["../src/policyactions.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Policy actions.\n *\n * @module     tool_policy/policyactions\n * @copyright  2018 Sara Arjona (sara@moodle.com)\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n    'jquery',\n    'core/ajax',\n    'core/notification',\n    'core/modal',\n], function($, Ajax, Notification, Modal) {\n\n    /**\n     * PolicyActions class.\n     *\n     * @param {jQuery} root\n     */\n    var PolicyActions = function(root) {\n        this.registerEvents(root);\n    };\n\n    /**\n     * Register event listeners.\n     *\n     * @param {jQuery} root\n     */\n    PolicyActions.prototype.registerEvents = function(root) {\n        root.on(\"click\", function(e) {\n            e.preventDefault();\n\n            var versionid = $(this).data('versionid');\n            var behalfid = $(this).data('behalfid');\n\n            var params = {\n                'versionid': versionid,\n                'behalfid': behalfid\n            };\n\n            var request = {\n                methodname: 'tool_policy_get_policy_version',\n                args: params\n            };\n\n            var modalTitle = $.Deferred();\n            var modalBody = $.Deferred();\n\n            var modal = Modal.create({\n                title: modalTitle,\n                body: modalBody,\n                large: true,\n                removeOnClose: true,\n                show: true,\n            })\n            .catch(Notification.exception);\n\n            // Make the request now that the modal is configured.\n            var promises = Ajax.call([request]);\n            $.when(promises[0]).then(function(data) {\n                if (data.result.policy) {\n                    modalTitle.resolve(data.result.policy.name);\n                    modalBody.resolve(data.result.policy.content);\n\n                    return data;\n                } else {\n                    throw new Error(data.warnings[0].message);\n                }\n            }).catch(function(message) {\n                modal.then(function(modal) {\n                    modal.hide();\n\n                    return modal;\n                })\n                .catch(Notification.exception);\n\n                return Notification.addNotification({\n                    message: message,\n                    type: 'error'\n                });\n            });\n        });\n\n    };\n\n    return /** @alias module:tool_policy/policyactions */ {\n        // Public variables and functions.\n\n        /**\n         * Initialise the actions helper.\n         *\n         * @method init\n         * @param {object} root\n         * @return {PolicyActions}\n         */\n        'init': function(root) {\n            root = $(root);\n            return new PolicyActions(root);\n        }\n    };\n});\n"],"names":["define","$","Ajax","Notification","Modal","PolicyActions","root","registerEvents","prototype","on","e","preventDefault","request","methodname","args","this","data","modalTitle","Deferred","modalBody","modal","create","title","body","large","removeOnClose","show","catch","exception","promises","call","when","then","result","policy","resolve","name","content","Error","warnings","message","hide","addNotification","type"],"mappings":";;;;;;;AAsBAA,mCAAO,CACH,SACA,YACA,oBACA,eACD,SAASC,EAAGC,KAAMC,aAAcC,WAO3BC,cAAgB,SAASC,WACpBC,eAAeD,cAQxBD,cAAcG,UAAUD,eAAiB,SAASD,MAC9CA,KAAKG,GAAG,SAAS,SAASC,GACtBA,EAAEC,qBAUEC,QAAU,CACVC,WAAY,iCACZC,KAPS,WAHGb,EAAEc,MAAMC,KAAK,sBACdf,EAAEc,MAAMC,KAAK,cAYxBC,WAAahB,EAAEiB,WACfC,UAAYlB,EAAEiB,WAEdE,MAAQhB,MAAMiB,OAAO,CACrBC,MAAOL,WACPM,KAAMJ,UACNK,OAAO,EACPC,eAAe,EACfC,MAAM,IAETC,MAAMxB,aAAayB,WAGhBC,SAAW3B,KAAK4B,KAAK,CAAClB,UAC1BX,EAAE8B,KAAKF,SAAS,IAAIG,MAAK,SAAShB,SAC1BA,KAAKiB,OAAOC,cACZjB,WAAWkB,QAAQnB,KAAKiB,OAAOC,OAAOE,MACtCjB,UAAUgB,QAAQnB,KAAKiB,OAAOC,OAAOG,SAE9BrB,WAED,IAAIsB,MAAMtB,KAAKuB,SAAS,GAAGC,YAEtCb,OAAM,SAASa,gBACdpB,MAAMY,MAAK,SAASZ,cAChBA,MAAMqB,OAECrB,SAEVO,MAAMxB,aAAayB,WAEbzB,aAAauC,gBAAgB,CAChCF,QAASA,QACTG,KAAM,iBAOgC,MAU1C,SAASrC,aACbA,KAAOL,EAAEK,MACF,IAAID,cAAcC"}