diff --git a/Gemfile.lock b/Gemfile.lock
index d981efe..6ef5a6b 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -221,6 +221,8 @@
pundit (1.1.0)
activesupport (>= 3.0.0)
rack (1.6.4)
+ rack-mini-profiler (0.10.1)
+ rack (>= 1.2.0)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.7)
@@ -345,6 +347,7 @@
omniauth-shibboleth
protected_attributes
pundit
+ rack-mini-profiler
rack-test
rails (= 4.2.7)
railties
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 68c3667..052fbc2 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -23,169 +23,170 @@
$( document ).ready(function() {
- $(function(){
- $('.dropdown-toggle').dropdown()
- });
+ $(function(){
+ $('.dropdown-toggle').dropdown()
+ });
- $('.accordion-body').on('show', function() {
- var plus = $(this).parent().children(".accordion-heading").children(".accordion-toggle").children(".icon-plus").removeClass("icon-plus").addClass("icon-minus");
- }).on('hide', function(){
- var minus = $(this).parent().children(".accordion-heading").children(".accordion-toggle").children(".icon-minus").removeClass("icon-minus").addClass("icon-plus");
- });
+ $('.accordion-body').on('show', function() {
+ var plus = $(this).parent().children(".accordion-heading").children(".accordion-toggle").children(".icon-plus").removeClass("icon-plus").addClass("icon-minus");
+ }).on('hide', function(){
+ var minus = $(this).parent().children(".accordion-heading").children(".accordion-toggle").children(".icon-minus").removeClass("icon-minus").addClass("icon-plus");
+ });
- //accordion home page
- $('.accordion-home').on('show', function() {
- var plus = $(this).parent().find(".plus-laranja").removeClass("plus-laranja").addClass("minus-laranja");
- }).on('hide', function(){
- var minus = $(this).parent().find(".minus-laranja").removeClass("minus-laranja").addClass("plus-laranja");
- });
+ //accordion home page
+ $('.accordion-home').on('show', function() {
+ var plus = $(this).parent().find(".plus-laranja").removeClass("plus-laranja").addClass("minus-laranja");
+ }).on('hide', function(){
+ var minus = $(this).parent().find(".minus-laranja").removeClass("minus-laranja").addClass("plus-laranja");
+ });
- //accordion project details page when project has more than 1 plan
- $('.accordion-project').on('show', function() {
- var plus = $(this).parent().find(".plus-laranja").removeClass("plus-laranja").addClass("minus-laranja");
- }).on('hide', function(){
- var minus = $(this).parent().find(".minus-laranja").removeClass("minus-laranja").addClass("plus-laranja");
- });
+ //accordion project details page when project has more than 1 plan
+ $('.accordion-project').on('show', function() {
+ var plus = $(this).parent().find(".plus-laranja").removeClass("plus-laranja").addClass("minus-laranja");
+ }).on('hide', function(){
+ var minus = $(this).parent().find(".minus-laranja").removeClass("minus-laranja").addClass("plus-laranja");
+ });
- //$('#3-or-4-splash').modal();
+ //$('#3-or-4-splash').modal();
- $('.typeahead').select2({
- width: "element",
- allowClear: true
- });
+ $('.typeahead').select2({
+ width: "element",
+ allowClear: true
+ });
- $(".help").popover();
+ $(".help").popover();
- $('.has-tooltip').tooltip({
+ $('.has-tooltip').tooltip({
placement: "right",
trigger: "focus"
- });
+ });
- $(".show-edit-toggle").click(function (e) {
- e.preventDefault();
-
- $(".edit-project").toggle();
- $(".view-project").toggle();
- });
+ $(".show-edit-toggle").click(function (e) {
+ e.preventDefault();
+
+ $(".edit-project").toggle();
+ $(".view-project").toggle();
+ });
- $(".toggle-existing-user-access").change(function(){
- $(this).closest("form").submit();
- });
+ $(".toggle-existing-user-access").change(function(){
+ $(this).closest("form").submit();
+ });
- $("#user_email.text_field.reg-input").blur(function () {
- if (validateEmail($(this).val())) {
- $(this).parent().children("div").hide();
- }
- else {
- $(this).parent().children("div").show();
- }
- });
+ $("#user_email.text_field.reg-input").blur(function () {
+ if (validateEmail($(this).val())) {
+ $(this).parent().children("div").hide();
+ }
+ else {
+ $(this).parent().children("div").show();
+ }
+ });
- $("#user_password.text_field.reg-input").blur(function () {
- if ($(this).val().length >= 8) {
- $(this).parent().children("div").hide();
- }
- else {
- $(this).parent().children("div").show();
- }
- });
+ $("#user_password.text_field.reg-input").blur(function () {
+ if ($(this).val().length >= 8) {
+ $(this).parent().children("div").hide();
+ }
+ else {
+ $(this).parent().children("div").show();
+ }
+ });
- $("#user_password_confirmation.text_field.reg-input").blur(function () {
- if ($(this).val() == $("#user_password.text_field.reg-input").val()) {
- $(this).parent().children("div").hide();
- }
- else {
- $(this).parent().children("div").show();
- }
- });
+ $("#user_password_confirmation.text_field.reg-input").blur(function () {
+ if ($(this).val() == $("#user_password.text_field.reg-input").val()) {
+ $(this).parent().children("div").hide();
+ }
+ else {
+ $(this).parent().children("div").show();
+ }
+ });
- $('#user_organisation_id').on("change", function(e) {
- e.preventDefault();
- var selected_org = $(this).select2("val");
- var other_orgs = $("#other-organisation-name").attr("data-orgs").split(",");
- var index = $.inArray(selected_org, other_orgs);
- if (index > -1) {
- $("#other-organisation-name").show();
- $("#user_other_organisation").focus();
- }
- else {
- $("#other-organisation-name").hide();
- }
- });
+ $('#user_organisation_id').on("change", function(e) {
+ e.preventDefault();
+ var selected_org = $(this).select2("val");
+ var other_orgs = $("#other-organisation-name").attr("data-orgs").split(",");
+ var index = $.inArray(selected_org, other_orgs);
+ if (index > -1) {
+ $("#other-organisation-name").show();
+ $("#user_other_organisation").focus();
+ }
+ else {
+ $("#other-organisation-name").hide();
+ }
+ });
- $("#other-org-link > a").click(function(e){
- e.preventDefault();
- var other_org = $("#other-organisation-name").attr("data-orgs").split(",");
- $("#user_organisation_id").select2("val", other_org);
- $("#other-org-link").hide();
- $("#user_organisation_id").change();
- });
+ $("#other-org-link > a").click(function(e){
+ e.preventDefault();
+ var other_org = $("#other-organisation-name").attr("data-orgs").split(",");
+ $("#user_organisation_id").select2("val", other_org);
+ $("#other-org-link").hide();
+ $("#user_organisation_id").change();
+ });
//alert dialog for unlink Shibbileth account
- $("#unlink-institutional-credentials-dialog").on("show", function(){
- $('.select2-choice').hide();
- });
+ $("#unlink-institutional-credentials-dialog").on("show", function(){
+ $('.select2-choice').hide();
+ });
- $("#unlink-shibboleth-cancelled").click(function (){
- $("#unlink-institutional-credentials-dialog").modal("hide");
- $('.select2-choice').show();
- });
+ $("#unlink-shibboleth-cancelled").click(function (){
+ $("#unlink-institutional-credentials-dialog").modal("hide");
+ $('.select2-choice').show();
+ });
- $("#unlink-shibboleth-confirmed").click(function (){
+ $("#unlink-shibboleth-confirmed").click(function (){
$("#unlink_flag").val('true');
- $("#edit_user").submit();
-
- });
+ $("#edit_user").submit();
+
+ });
- //Question Options
- // ------------------------------------------------------------------------------------
- $(".options_table").on("click", ".remove-option", function(e){
- e.preventDefault();
-
- // Mark the option for removal
- $($(this).siblings()[0]).val(true);
-
- // Hide the entire table row and the associated hidden field for the item
- $(this).parent().parent().addClass('hidden');
- });
-
- $(".add-option").click(function(e){
- e.preventDefault();
+ //Question Options
+ // ---------------------------------------------------------------------------
+ $(".options_table").on("click", ".remove-option", function(e){
+ e.preventDefault();
+
+ // Mark the option for removal
+ $($(this).siblings()[0]).val(true);
+
+ // Hide the entire table row and the associated hidden field for the item
+ $(this).parent().parent().addClass('hidden');
+ });
+
+ $(".add-option").click(function(e){
+ e.preventDefault();
- var tbl = $(this).parent().find("table.options_table > tbody.options_tbody"),
- last = tbl.find("tr:last"),
- clone = last.clone();
- nbr = parseInt(last.find(".number_field").val());
-
- // Update the input field names and ids
- clone.find("input").each(function(index){
- $(this).prop("id", $(this).prop("id").replace(/_\d+_/g, "_" + nbr + "_"));
- $(this).prop("name", $(this).prop("name").replace(/\[\d+\]/g, "[" + nbr + "]"));
- });
-
- // Remove the hidden class and make sure the new row is not marked for removal
- clone.removeClass('hidden');
- clone.find("[id$=" + nbr + "__destroy]").val(false);
-
- // Default the other values
- clone.find("[id$=" + nbr + "_number]").val("" + (nbr + 1));
- clone.find("[id$=" + nbr + "_text]").val("");
- clone.find("[id$=" + nbr + "_is_default]").prop("checked", false);
-
- last.after(clone);
- });
+ var tbl = $(this).parent().find("table.options_table > tbody.options_tbody"),
+ last = tbl.find("tr:last"),
+ clone = last.clone();
+ nbr = parseInt(last.find(".number_field").val());
+
+ // Update the input field names and ids
+ clone.find("input").each(function(index){
+ $(this).prop("id", $(this).prop("id").replace(/_\d+_/g, "_" + nbr + "_"));
+ $(this).prop("name", $(this).prop("name").replace(/\[\d+\]/g, "[" + nbr + "]"));
+ });
+
+ // Remove the hidden class and make sure the new row is not marked for removal
+ clone.removeClass('hidden');
+ clone.find("[id$=" + nbr + "__destroy]").val(false);
+
+ // Default the other values
+ clone.find("[id$=" + nbr + "_number]").val("" + (nbr + 1));
+ clone.find("[id$=" + nbr + "_text]").val("");
+ clone.find("[id$=" + nbr + "_is_default]").prop("checked", false);
+
+ last.after(clone);
+ });
- /*$('#continue-to-new').click(function(e){
- var destination = $(this).attr("href");
- var n = destination.lastIndexOf('=');
- destination = decodeURIComponent(destination.substring(n + 1));
- $.post('splash_logs', {destination: destination} );
- $("#3-or-4-splash").modal('hide');
- return false;
- });*/
+ /*$('#continue-to-new').click(function(e){
+ var destination = $(this).attr("href");
+ var n = destination.lastIndexOf('=');
+ destination = decodeURIComponent(destination.substring(n + 1));
+ $.post('splash_logs', {destination: destination} );
+ $("#3-or-4-splash").modal('hide');
+ return false;
+ });*/
});
+// ---------------------------------------------------------------------------
function validateEmail(sEmail) {
var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;
if (filter.test(sEmail)) {
@@ -195,3 +196,25 @@
return false;
}
}
+
+// ---------------------------------------------------------------------------
+function selectItemsFromJsonArray(array, selector, array_of_values, callback){
+ var out = [];
+
+ if(!Array.isArray(array_of_values)){
+ array_of_values = [array_of_values];
+ }
+
+ for(var i = 0; i < array.length; i++){
+ if(array_of_values.indexOf('' + array[i][selector]) >= 0){
+ out.push(array[i]);
+ }
+ }
+
+ var selectItemsFromJsonArrayInterval = setInterval(function(){
+ if(i >= array.length){
+ clearInterval(selectItemsFromJsonArrayInterval);
+ callback(out);
+ }
+ }, 50);
+}
\ No newline at end of file
diff --git a/app/assets/javascripts/projects.js b/app/assets/javascripts/projects.js
index c103f84..b2db6ea 100644
--- a/app/assets/javascripts/projects.js
+++ b/app/assets/javascripts/projects.js
@@ -1,169 +1,189 @@
$( document ).ready(function() {
+ $(".select2-container").select2();
-/*
- $("#project_funder_id").select2({
- placeholder: "Select a funder"
- });
-*/
- $("#project_funder_id").change(function () {
- update_template_options();
- update_guidance_options();
- if ($(this).val().length > 0) {
- $("#other-funder-name").hide();
- $("#project_funder_name").val("");
- }
- else {
- $("#other-funder-name").show();
- }
- $("#institution-control-group").show();
- $("#create-plan-button").show();
- $("#confirm-funder").text($("#project_funder_id").select2('data').text);
- });
+ // ----------------------------------------------------------
+ $("#project_funder_id").change(function(){
+ reloadTemplateData();
+
+ if($(this).val().length > 0){
+ $("#other-funder-name").hide();
+ $("#project_funder_name").val("");
+
+ }else{
+ $("#other-funder-name").show();
+ }
+
+ $("#institution-control-group").show();
+ $("#create-plan-button").show();
+ $("#confirm-funder").text($(this).val());
+ });
+
+ // ----------------------------------------------------------
+ $("#project_institution_id").change(function(){
+ reloadTemplateData();
+
+ $("#confirm-institution").text($("#project_institution_id").select2('data').text);
+ });
+
+ // ----------------------------------------------------------
+ $("#project_dmptemplate_id").change(function(){
+ reloadGuidanceOptions();
+ });
+
+ // ----------------------------------------------------------
+ $("#no-funder").click(function(e) {
+ e.preventDefault();
+ $("#project_funder_id").select2("val", "");
+ $("#institution-control-group").show();
+ $("#create-plan-button").show();
+ $("#other-funder-name").show();
+ $("#confirm-funder").text(I18n.t("helpers.none"));
+ });
- $("#no-funder").click(function(e) {
- e.preventDefault();
- $("#project_funder_id").select2("val", "");
- update_template_options();
- update_guidance_options();
- $("#institution-control-group").show();
- $("#create-plan-button").show();
- $("#other-funder-name").show();
- $("#confirm-funder").text(I18n.t("helpers.none"));
- });
+ // ----------------------------------------------------------
+ $("#project_funder_name").change(function(){
+ $("#confirm-funder").text($(this).val());
+ });
- $("#project_funder_name").change(function(){
- $("#confirm-funder").text($(this).val());
- });
+ // ----------------------------------------------------------
+ $("#no-institution").click(function() {
+ $("#project_institution_id").select2("val", "");
+ $("#confirm-institution").text(I18n.t("helpers.none"));
+ });
+
+ // ----------------------------------------------------------
+ $("#project-confirmation-dialog").on("show", function(){
+ if ($("#confirm-institution").text() == "") {
+ $("#confirm-institution").text(I18n.t("helpers.none"));
+ }
+ if ($("#confirm-funder").text() == "") {
+ $("#confirm-funder").text(I18n.t("helpers.none"));
+ }
+ if ($("#confirm-template").text() == "") {
+ $("#confirm-template").closest("div").hide();
+ }
+ else {
+ $("#confirm-template").closest("div").show();
+ }
+ $("#confirm-guidance").empty();
+ $("input:checked").each(function(){
+ $("#confirm-guidance").append("
"+$(this).parent().text()+" ");
+ });
+ $('.select2-choice').hide();
+ });
- $("#project_institution_id").change(function () {
- update_template_options();
- update_guidance_options();
- $("#confirm-institution").text($("#project_institution_id").select2('data').text);
- });
+ // ----------------------------------------------------------
+ $("#new-project-cancelled").click(function (){
+ $("#project-confirmation-dialog").modal("hide");
+ $('.select2-choice').show();
+ });
- $("#no-institution").click(function() {
- $("#project_institution_id").select2("val", "");
- update_template_options();
- update_guidance_options();
- $("#confirm-institution").text(I18n.t("helpers.none"));
- });
+ // ----------------------------------------------------------
+ $("#new-project-confirmed").click(function (){
+ $("#new_project").submit();
+ });
- $("#project_dmptemplate_id").change(function (f) {
- update_guidance_options();
- $("#confirm-template").text($("#project_dmptemplate_id :selected").text());
- });
+ // ----------------------------------------------------------
+ //for the default template alert
+ $("#default-template-confirmation-dialog").on("show", function(){
+ $('.select2-choice').hide();
+ });
- $("#project-confirmation-dialog").on("show", function(){
- if ($("#confirm-institution").text() == "") {
- $("#confirm-institution").text(I18n.t("helpers.none"));
- }
- if ($("#confirm-funder").text() == "") {
- $("#confirm-funder").text(I18n.t("helpers.none"));
- }
- if ($("#confirm-template").text() == "") {
- $("#confirm-template").closest("div").hide();
- }
- else {
- $("#confirm-template").closest("div").show();
- }
- $("#confirm-guidance").empty();
- $("input:checked").each(function(){
- $("#confirm-guidance").append(""+$(this).parent().text()+" ");
- });
- $('.select2-choice').hide();
- });
+ // ----------------------------------------------------------
+ $("#default-template-cancelled").click(function (){
+ $("#default-template-confirmation-dialog").modal("hide");
+ $('.select2-choice').show();
+ });
- $("#new-project-cancelled").click(function (){
- $("#project-confirmation-dialog").modal("hide");
- $('.select2-choice').show();
- });
+ // ----------------------------------------------------------
+ $("#default-template-confirmed").click(function (){
+ $("#default_tag").val('true');
+ $("#new_project").submit();
+ });
+
+
+ // The following function references a JSON array that is
+ // constructed in app/view/projects/_dropdown_new_project.html.erb
+ // ----------------------------------------------------------
+ function reloadTemplateData(){
+ var orgs = [$("#project_funder_id").val(),
+ $("#project_institution_id").val()];
+
+ var template = $("#project_dmptemplate_id :selected").val();
+
+ selectItemsFromJsonArray(templates, 'organisation', orgs, function(array){
+ // Clear and reload the contents of the dropdown
+ $("#project_dmptemplate_id").html("").select2( {data: array} ).val();
- $("#new-project-confirmed").click(function (){
- $("#new_project").submit();
- });
+ // If there are no templates, hide the dropdown
+ if(array.length <= 0){
+ $("#template-control-group").hide();
+ reloadGuidanceOptions();
+
+ }else{
+ // Select the first item in the list if there was none selected
+ if(template == undefined){
+ $("#project_dmptemplate_id").val(array[0]['id']).trigger('change');
+
+ }else{
+ reloadGuidanceOptions();
+ }
+
+ $("#template-control-group").show();
- //for the default template alert
- $("#default-template-confirmation-dialog").on("show", function(){
- $('.select2-choice').hide();
- });
+ // if there is only one template disable the dropdown
+ if(array.length > 1){
+ $("#project_dmptemplate_id").prop('disabled', false);
+ }else{
+ $("#project_dmptemplate_id").prop('disabled', true);
+ }
+ }
+ });
+ }
- $("#default-template-cancelled").click(function (){
- $("#default-template-confirmation-dialog").modal("hide");
- $('.select2-choice').show();
- });
+ // The following function references a JSON array that is
+ // constructed in app/view/projects/_dropdown_new_project.html.erb
+ // ----------------------------------------------------------
+ function reloadGuidanceOptions() {
+ var institution = $("#project_institution_id").select2('val');
+ var template = $("#project_dmptemplate_id :selected").val();
+ var options = null;
+
+ if(!template){
+ template = $("#project_dmptemplate_id :selected").children().first().val();
+ }
+
+ options_container = $("#guidance-control-group");
+ options_container = options_container.find(".choices-group");
+ options_container.empty();
+
+ var orgs = [$("#project_funder_id").val(),
+ $("#project_institution_id").val()];
- $("#default-template-confirmed").click(function (){
- $("#default_tag").val('true');
- $("#new_project").submit();
- });
-
-
- function update_template_options() {
- var options = {};
- var funder = $("#project_funder_id").select2('val');
- var institution = $("#project_institution_id").select2('val');
- $.ajax({
- type: 'GET',
- url: "possible_templates.json?institution="+institution+"&funder="+funder,
- dataType: 'json',
- async: false, //Needs to be synchronous, otherwise end up mixing up answers
- success: function(data) {
- options = data;
- }
- });
- select_element = $("#project_dmptemplate_id");
- select_element.find("option").remove();
- var count = 0;
- for (var id in options) {
- if (count == 0) {
- select_element.append(""+options[id]+" ");
- }
- else {
- select_element.append(""+options[id]+" ");
- }
- count++;
- }
- if (count >= 2) {
- $("#template-control-group").show();
- }
- else {
- $("#template-control-group").hide();
- }
- $("#confirm-template").text("");
- $("#project_dmptemplate_id").change();
- }
-
- function update_guidance_options() {
- var institution = $("#project_institution_id").select2('val');
- var template = $("#project_dmptemplate_id :selected").val();
- var options = null;
-
- $.ajax({
- type: 'GET',
- url: "possible_guidance.json?institution="+institution+"&template="+template,
- dataType: 'json',
- async: false, //Needs to be synchronous, otherwise end up mixing up answers
- success: function(data) {
- options = data;
- },
- error: function(err){
- console.log(err);
- }
- });
- options_container = $("#guidance-control-group");
- options_container = options_container.find(".choices-group");
- options_container.empty();
-
- var count = 0;
- for (var id in options) {
- options_container.append(" "+options[id]+" ");
- count++;
- }
- if (count > 0) {
- $("#guidance-control-group").show();
- }
- else {
- $("#guidance-control-group").hide();
- }
- }
+ // select all of the guidance groups available to the funder and/or institution
+ selectItemsFromJsonArray(guidance_for_template_or_organisation, 'organisation',
+ institution, function(array){
+ array = guidance_always_available.concat(array);
+
+ for(var i = 0; i < array.length; i++){
+ var selected = false
+
+ options_container.append(
+ "" +
+ "" +
+ " " +
+ array[i]['text'] + " " +
+ " "
+ );
+ }
+
+ if(array.length > 0){
+ $("#guidance-control-group").show();
+ }else{
+ $("#guidance-control-group").hide();
+ }
+ });
+ }
});
diff --git a/app/assets/javascripts/select2.min.js b/app/assets/javascripts/select2.min.js
index 1aa2d30..c668840 100644
--- a/app/assets/javascripts/select2.min.js
+++ b/app/assets/javascripts/select2.min.js
@@ -1,22 +1,3 @@
-/*
-Copyright 2012 Igor Vaynberg
-
-Version: 3.4.2 Timestamp: Mon Aug 12 15:04:12 PDT 2013
-
-This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
-General Public License version 2 (the "GPL License"). You may choose either license to govern your
-use of this software only upon the condition that you accept all of the terms of either the Apache
-License or the GPL License.
-
-You may obtain a copy of the Apache License and the GPL License at:
-
-http://www.apache.org/licenses/LICENSE-2.0
-http://www.gnu.org/licenses/gpl-2.0.html
-
-Unless required by applicable law or agreed to in writing, software distributed under the Apache License
-or the GPL Licesnse is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-either express or implied. See the Apache License and the GPL License for the specific language governing
-permissions and limitations under the Apache License and the GPL License.
-*/
-!function(a){"undefined"==typeof a.fn.each2&&a.extend(a.fn,{each2:function(b){for(var c=a([0]),d=-1,e=this.length;++dc;c++)e=a.charAt(c),b+=m[e]||e;return b}function o(a,b){for(var c=0,d=b.length;d>c;c+=1)if(q(a,b[c]))return c;return-1}function p(){var b=a(l);b.appendTo("body");var c={width:b.width()-b[0].clientWidth,height:b.height()-b[0].clientHeight};return b.remove(),c}function q(a,c){return a===c?!0:a===b||c===b?!1:null===a||null===c?!1:a.constructor===String?a+""==c+"":c.constructor===String?c+""==a+"":!1}function r(b,c){var d,e,f;if(null===b||b.length<1)return[];for(d=b.split(c),e=0,f=d.length;f>e;e+=1)d[e]=a.trim(d[e]);return d}function s(a){return a.outerWidth(!1)-a.width()}function t(c){var d="keyup-change-value";c.on("keydown",function(){a.data(c,d)===b&&a.data(c,d,c.val())}),c.on("keyup",function(){var e=a.data(c,d);e!==b&&c.val()!==e&&(a.removeData(c,d),c.trigger("keyup-change"))})}function u(c){c.on("mousemove",function(c){var d=i;(d===b||d.x!==c.pageX||d.y!==c.pageY)&&a(c.target).trigger("mousemove-filtered",c)})}function v(a,c,d){d=d||b;var e;return function(){var b=arguments;window.clearTimeout(e),e=window.setTimeout(function(){c.apply(d,b)},a)}}function w(a){var c,b=!1;return function(){return b===!1&&(c=a(),b=!0),c}}function x(a,b){var c=v(a,function(a){b.trigger("scroll-debounced",a)});b.on("scroll",function(a){o(a.target,b.get())>=0&&c(a)})}function y(a){a[0]!==document.activeElement&&window.setTimeout(function(){var d,b=a[0],c=a.val().length;a.focus(),a.is(":visible")&&b===document.activeElement&&(b.setSelectionRange?b.setSelectionRange(c,c):b.createTextRange&&(d=b.createTextRange(),d.collapse(!1),d.select()))},0)}function z(b){b=a(b)[0];var c=0,d=0;if("selectionStart"in b)c=b.selectionStart,d=b.selectionEnd-c;else if("selection"in document){b.focus();var e=document.selection.createRange();d=document.selection.createRange().text.length,e.moveStart("character",-b.value.length),c=e.text.length-d}return{offset:c,length:d}}function A(a){a.preventDefault(),a.stopPropagation()}function B(a){a.preventDefault(),a.stopImmediatePropagation()}function C(b){if(!h){var c=b[0].currentStyle||window.getComputedStyle(b[0],null);h=a(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:c.fontSize,fontFamily:c.fontFamily,fontStyle:c.fontStyle,fontWeight:c.fontWeight,letterSpacing:c.letterSpacing,textTransform:c.textTransform,whiteSpace:"nowrap"}),h.attr("class","select2-sizer"),a("body").append(h)}return h.text(b.val()),h.width()}function D(b,c,d){var e,g,f=[];e=b.attr("class"),e&&(e=""+e,a(e.split(" ")).each2(function(){0===this.indexOf("select2-")&&f.push(this)})),e=c.attr("class"),e&&(e=""+e,a(e.split(" ")).each2(function(){0!==this.indexOf("select2-")&&(g=d(this),g&&f.push(this))})),b.attr("class",f.join(" "))}function E(a,b,c,d){var e=n(a.toUpperCase()).indexOf(n(b.toUpperCase())),f=b.length;return 0>e?(c.push(d(a)),void 0):(c.push(d(a.substring(0,e))),c.push(""),c.push(d(a.substring(e,e+f))),c.push(" "),c.push(d(a.substring(e+f,a.length))),void 0)}function F(a){var b={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(a).replace(/[&<>"'\/\\]/g,function(a){return b[a]})}function G(c){var d,e=null,f=c.quietMillis||100,g=c.url,h=this;return function(i){window.clearTimeout(d),d=window.setTimeout(function(){var d=c.data,f=g,j=c.transport||a.fn.select2.ajaxDefaults.transport,k={type:c.type||"GET",cache:c.cache||!1,jsonpCallback:c.jsonpCallback||b,dataType:c.dataType||"json"},l=a.extend({},a.fn.select2.ajaxDefaults.params,k);d=d?d.call(h,i.term,i.page,i.context):null,f="function"==typeof f?f.call(h,i.term,i.page,i.context):f,e&&e.abort(),c.params&&(a.isFunction(c.params)?a.extend(l,c.params.call(h)):a.extend(l,c.params)),a.extend(l,{url:f,dataType:c.dataType,data:d,success:function(a){var b=c.results(a,i.page);i.callback(b)}}),e=j.call(h,l)},f)}}function H(b){var d,e,c=b,f=function(a){return""+a.text};a.isArray(c)&&(e=c,c={results:e}),a.isFunction(c)===!1&&(e=c,c=function(){return e});var g=c();return g.text&&(f=g.text,a.isFunction(f)||(d=g.text,f=function(a){return a[d]})),function(b){var g,d=b.term,e={results:[]};return""===d?(b.callback(c()),void 0):(g=function(c,e){var h,i;if(c=c[0],c.children){h={};for(i in c)c.hasOwnProperty(i)&&(h[i]=c[i]);h.children=[],a(c.children).each2(function(a,b){g(b,h.children)}),(h.children.length||b.matcher(d,f(h),c))&&e.push(h)}else b.matcher(d,f(c),c)&&e.push(c)},a(c().results).each2(function(a,b){g(b,e.results)}),b.callback(e),void 0)}}function I(c){var d=a.isFunction(c);return function(e){var f=e.term,g={results:[]};a(d?c():c).each(function(){var a=this.text!==b,c=a?this.text:this;(""===f||e.matcher(f,c))&&g.results.push(a?this:{id:this,text:this})}),e.callback(g)}}function J(b,c){if(a.isFunction(b))return!0;if(!b)return!1;throw new Error(c+" must be a function or a falsy value")}function K(b){return a.isFunction(b)?b():b}function L(b){var c=0;return a.each(b,function(a,b){b.children?c+=L(b.children):c++}),c}function M(a,c,d,e){var h,i,j,k,l,f=a,g=!1;if(!e.createSearchChoice||!e.tokenSeparators||e.tokenSeparators.length<1)return b;for(;;){for(i=-1,j=0,k=e.tokenSeparators.length;k>j&&(l=e.tokenSeparators[j],i=a.indexOf(l),!(i>=0));j++);if(0>i)break;if(h=a.substring(0,i),a=a.substring(i+l.length),h.length>0&&(h=e.createSearchChoice.call(this,h,c),h!==b&&null!==h&&e.id(h)!==b&&null!==e.id(h))){for(g=!1,j=0,k=c.length;k>j;j++)if(q(e.id(h),e.id(c[j]))){g=!0;break}g||d(h)}}return f!==a?a:void 0}function N(b,c){var d=function(){};return d.prototype=new b,d.prototype.constructor=d,d.prototype.parent=b.prototype,d.prototype=a.extend(d.prototype,c),d}if(window.Select2===b){var c,d,e,f,g,h,j,k,i={x:0,y:0},c={TAB:9,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,SHIFT:16,CTRL:17,ALT:18,PAGE_UP:33,PAGE_DOWN:34,HOME:36,END:35,BACKSPACE:8,DELETE:46,isArrow:function(a){switch(a=a.which?a.which:a){case c.LEFT:case c.RIGHT:case c.UP:case c.DOWN:return!0}return!1},isControl:function(a){var b=a.which;switch(b){case c.SHIFT:case c.CTRL:case c.ALT:return!0}return a.metaKey?!0:!1},isFunctionKey:function(a){return a=a.which?a.which:a,a>=112&&123>=a}},l="
",m={"\u24b6":"A","\uff21":"A","\xc0":"A","\xc1":"A","\xc2":"A","\u1ea6":"A","\u1ea4":"A","\u1eaa":"A","\u1ea8":"A","\xc3":"A","\u0100":"A","\u0102":"A","\u1eb0":"A","\u1eae":"A","\u1eb4":"A","\u1eb2":"A","\u0226":"A","\u01e0":"A","\xc4":"A","\u01de":"A","\u1ea2":"A","\xc5":"A","\u01fa":"A","\u01cd":"A","\u0200":"A","\u0202":"A","\u1ea0":"A","\u1eac":"A","\u1eb6":"A","\u1e00":"A","\u0104":"A","\u023a":"A","\u2c6f":"A","\ua732":"AA","\xc6":"AE","\u01fc":"AE","\u01e2":"AE","\ua734":"AO","\ua736":"AU","\ua738":"AV","\ua73a":"AV","\ua73c":"AY","\u24b7":"B","\uff22":"B","\u1e02":"B","\u1e04":"B","\u1e06":"B","\u0243":"B","\u0182":"B","\u0181":"B","\u24b8":"C","\uff23":"C","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\xc7":"C","\u1e08":"C","\u0187":"C","\u023b":"C","\ua73e":"C","\u24b9":"D","\uff24":"D","\u1e0a":"D","\u010e":"D","\u1e0c":"D","\u1e10":"D","\u1e12":"D","\u1e0e":"D","\u0110":"D","\u018b":"D","\u018a":"D","\u0189":"D","\ua779":"D","\u01f1":"DZ","\u01c4":"DZ","\u01f2":"Dz","\u01c5":"Dz","\u24ba":"E","\uff25":"E","\xc8":"E","\xc9":"E","\xca":"E","\u1ec0":"E","\u1ebe":"E","\u1ec4":"E","\u1ec2":"E","\u1ebc":"E","\u0112":"E","\u1e14":"E","\u1e16":"E","\u0114":"E","\u0116":"E","\xcb":"E","\u1eba":"E","\u011a":"E","\u0204":"E","\u0206":"E","\u1eb8":"E","\u1ec6":"E","\u0228":"E","\u1e1c":"E","\u0118":"E","\u1e18":"E","\u1e1a":"E","\u0190":"E","\u018e":"E","\u24bb":"F","\uff26":"F","\u1e1e":"F","\u0191":"F","\ua77b":"F","\u24bc":"G","\uff27":"G","\u01f4":"G","\u011c":"G","\u1e20":"G","\u011e":"G","\u0120":"G","\u01e6":"G","\u0122":"G","\u01e4":"G","\u0193":"G","\ua7a0":"G","\ua77d":"G","\ua77e":"G","\u24bd":"H","\uff28":"H","\u0124":"H","\u1e22":"H","\u1e26":"H","\u021e":"H","\u1e24":"H","\u1e28":"H","\u1e2a":"H","\u0126":"H","\u2c67":"H","\u2c75":"H","\ua78d":"H","\u24be":"I","\uff29":"I","\xcc":"I","\xcd":"I","\xce":"I","\u0128":"I","\u012a":"I","\u012c":"I","\u0130":"I","\xcf":"I","\u1e2e":"I","\u1ec8":"I","\u01cf":"I","\u0208":"I","\u020a":"I","\u1eca":"I","\u012e":"I","\u1e2c":"I","\u0197":"I","\u24bf":"J","\uff2a":"J","\u0134":"J","\u0248":"J","\u24c0":"K","\uff2b":"K","\u1e30":"K","\u01e8":"K","\u1e32":"K","\u0136":"K","\u1e34":"K","\u0198":"K","\u2c69":"K","\ua740":"K","\ua742":"K","\ua744":"K","\ua7a2":"K","\u24c1":"L","\uff2c":"L","\u013f":"L","\u0139":"L","\u013d":"L","\u1e36":"L","\u1e38":"L","\u013b":"L","\u1e3c":"L","\u1e3a":"L","\u0141":"L","\u023d":"L","\u2c62":"L","\u2c60":"L","\ua748":"L","\ua746":"L","\ua780":"L","\u01c7":"LJ","\u01c8":"Lj","\u24c2":"M","\uff2d":"M","\u1e3e":"M","\u1e40":"M","\u1e42":"M","\u2c6e":"M","\u019c":"M","\u24c3":"N","\uff2e":"N","\u01f8":"N","\u0143":"N","\xd1":"N","\u1e44":"N","\u0147":"N","\u1e46":"N","\u0145":"N","\u1e4a":"N","\u1e48":"N","\u0220":"N","\u019d":"N","\ua790":"N","\ua7a4":"N","\u01ca":"NJ","\u01cb":"Nj","\u24c4":"O","\uff2f":"O","\xd2":"O","\xd3":"O","\xd4":"O","\u1ed2":"O","\u1ed0":"O","\u1ed6":"O","\u1ed4":"O","\xd5":"O","\u1e4c":"O","\u022c":"O","\u1e4e":"O","\u014c":"O","\u1e50":"O","\u1e52":"O","\u014e":"O","\u022e":"O","\u0230":"O","\xd6":"O","\u022a":"O","\u1ece":"O","\u0150":"O","\u01d1":"O","\u020c":"O","\u020e":"O","\u01a0":"O","\u1edc":"O","\u1eda":"O","\u1ee0":"O","\u1ede":"O","\u1ee2":"O","\u1ecc":"O","\u1ed8":"O","\u01ea":"O","\u01ec":"O","\xd8":"O","\u01fe":"O","\u0186":"O","\u019f":"O","\ua74a":"O","\ua74c":"O","\u01a2":"OI","\ua74e":"OO","\u0222":"OU","\u24c5":"P","\uff30":"P","\u1e54":"P","\u1e56":"P","\u01a4":"P","\u2c63":"P","\ua750":"P","\ua752":"P","\ua754":"P","\u24c6":"Q","\uff31":"Q","\ua756":"Q","\ua758":"Q","\u024a":"Q","\u24c7":"R","\uff32":"R","\u0154":"R","\u1e58":"R","\u0158":"R","\u0210":"R","\u0212":"R","\u1e5a":"R","\u1e5c":"R","\u0156":"R","\u1e5e":"R","\u024c":"R","\u2c64":"R","\ua75a":"R","\ua7a6":"R","\ua782":"R","\u24c8":"S","\uff33":"S","\u1e9e":"S","\u015a":"S","\u1e64":"S","\u015c":"S","\u1e60":"S","\u0160":"S","\u1e66":"S","\u1e62":"S","\u1e68":"S","\u0218":"S","\u015e":"S","\u2c7e":"S","\ua7a8":"S","\ua784":"S","\u24c9":"T","\uff34":"T","\u1e6a":"T","\u0164":"T","\u1e6c":"T","\u021a":"T","\u0162":"T","\u1e70":"T","\u1e6e":"T","\u0166":"T","\u01ac":"T","\u01ae":"T","\u023e":"T","\ua786":"T","\ua728":"TZ","\u24ca":"U","\uff35":"U","\xd9":"U","\xda":"U","\xdb":"U","\u0168":"U","\u1e78":"U","\u016a":"U","\u1e7a":"U","\u016c":"U","\xdc":"U","\u01db":"U","\u01d7":"U","\u01d5":"U","\u01d9":"U","\u1ee6":"U","\u016e":"U","\u0170":"U","\u01d3":"U","\u0214":"U","\u0216":"U","\u01af":"U","\u1eea":"U","\u1ee8":"U","\u1eee":"U","\u1eec":"U","\u1ef0":"U","\u1ee4":"U","\u1e72":"U","\u0172":"U","\u1e76":"U","\u1e74":"U","\u0244":"U","\u24cb":"V","\uff36":"V","\u1e7c":"V","\u1e7e":"V","\u01b2":"V","\ua75e":"V","\u0245":"V","\ua760":"VY","\u24cc":"W","\uff37":"W","\u1e80":"W","\u1e82":"W","\u0174":"W","\u1e86":"W","\u1e84":"W","\u1e88":"W","\u2c72":"W","\u24cd":"X","\uff38":"X","\u1e8a":"X","\u1e8c":"X","\u24ce":"Y","\uff39":"Y","\u1ef2":"Y","\xdd":"Y","\u0176":"Y","\u1ef8":"Y","\u0232":"Y","\u1e8e":"Y","\u0178":"Y","\u1ef6":"Y","\u1ef4":"Y","\u01b3":"Y","\u024e":"Y","\u1efe":"Y","\u24cf":"Z","\uff3a":"Z","\u0179":"Z","\u1e90":"Z","\u017b":"Z","\u017d":"Z","\u1e92":"Z","\u1e94":"Z","\u01b5":"Z","\u0224":"Z","\u2c7f":"Z","\u2c6b":"Z","\ua762":"Z","\u24d0":"a","\uff41":"a","\u1e9a":"a","\xe0":"a","\xe1":"a","\xe2":"a","\u1ea7":"a","\u1ea5":"a","\u1eab":"a","\u1ea9":"a","\xe3":"a","\u0101":"a","\u0103":"a","\u1eb1":"a","\u1eaf":"a","\u1eb5":"a","\u1eb3":"a","\u0227":"a","\u01e1":"a","\xe4":"a","\u01df":"a","\u1ea3":"a","\xe5":"a","\u01fb":"a","\u01ce":"a","\u0201":"a","\u0203":"a","\u1ea1":"a","\u1ead":"a","\u1eb7":"a","\u1e01":"a","\u0105":"a","\u2c65":"a","\u0250":"a","\ua733":"aa","\xe6":"ae","\u01fd":"ae","\u01e3":"ae","\ua735":"ao","\ua737":"au","\ua739":"av","\ua73b":"av","\ua73d":"ay","\u24d1":"b","\uff42":"b","\u1e03":"b","\u1e05":"b","\u1e07":"b","\u0180":"b","\u0183":"b","\u0253":"b","\u24d2":"c","\uff43":"c","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\xe7":"c","\u1e09":"c","\u0188":"c","\u023c":"c","\ua73f":"c","\u2184":"c","\u24d3":"d","\uff44":"d","\u1e0b":"d","\u010f":"d","\u1e0d":"d","\u1e11":"d","\u1e13":"d","\u1e0f":"d","\u0111":"d","\u018c":"d","\u0256":"d","\u0257":"d","\ua77a":"d","\u01f3":"dz","\u01c6":"dz","\u24d4":"e","\uff45":"e","\xe8":"e","\xe9":"e","\xea":"e","\u1ec1":"e","\u1ebf":"e","\u1ec5":"e","\u1ec3":"e","\u1ebd":"e","\u0113":"e","\u1e15":"e","\u1e17":"e","\u0115":"e","\u0117":"e","\xeb":"e","\u1ebb":"e","\u011b":"e","\u0205":"e","\u0207":"e","\u1eb9":"e","\u1ec7":"e","\u0229":"e","\u1e1d":"e","\u0119":"e","\u1e19":"e","\u1e1b":"e","\u0247":"e","\u025b":"e","\u01dd":"e","\u24d5":"f","\uff46":"f","\u1e1f":"f","\u0192":"f","\ua77c":"f","\u24d6":"g","\uff47":"g","\u01f5":"g","\u011d":"g","\u1e21":"g","\u011f":"g","\u0121":"g","\u01e7":"g","\u0123":"g","\u01e5":"g","\u0260":"g","\ua7a1":"g","\u1d79":"g","\ua77f":"g","\u24d7":"h","\uff48":"h","\u0125":"h","\u1e23":"h","\u1e27":"h","\u021f":"h","\u1e25":"h","\u1e29":"h","\u1e2b":"h","\u1e96":"h","\u0127":"h","\u2c68":"h","\u2c76":"h","\u0265":"h","\u0195":"hv","\u24d8":"i","\uff49":"i","\xec":"i","\xed":"i","\xee":"i","\u0129":"i","\u012b":"i","\u012d":"i","\xef":"i","\u1e2f":"i","\u1ec9":"i","\u01d0":"i","\u0209":"i","\u020b":"i","\u1ecb":"i","\u012f":"i","\u1e2d":"i","\u0268":"i","\u0131":"i","\u24d9":"j","\uff4a":"j","\u0135":"j","\u01f0":"j","\u0249":"j","\u24da":"k","\uff4b":"k","\u1e31":"k","\u01e9":"k","\u1e33":"k","\u0137":"k","\u1e35":"k","\u0199":"k","\u2c6a":"k","\ua741":"k","\ua743":"k","\ua745":"k","\ua7a3":"k","\u24db":"l","\uff4c":"l","\u0140":"l","\u013a":"l","\u013e":"l","\u1e37":"l","\u1e39":"l","\u013c":"l","\u1e3d":"l","\u1e3b":"l","\u017f":"l","\u0142":"l","\u019a":"l","\u026b":"l","\u2c61":"l","\ua749":"l","\ua781":"l","\ua747":"l","\u01c9":"lj","\u24dc":"m","\uff4d":"m","\u1e3f":"m","\u1e41":"m","\u1e43":"m","\u0271":"m","\u026f":"m","\u24dd":"n","\uff4e":"n","\u01f9":"n","\u0144":"n","\xf1":"n","\u1e45":"n","\u0148":"n","\u1e47":"n","\u0146":"n","\u1e4b":"n","\u1e49":"n","\u019e":"n","\u0272":"n","\u0149":"n","\ua791":"n","\ua7a5":"n","\u01cc":"nj","\u24de":"o","\uff4f":"o","\xf2":"o","\xf3":"o","\xf4":"o","\u1ed3":"o","\u1ed1":"o","\u1ed7":"o","\u1ed5":"o","\xf5":"o","\u1e4d":"o","\u022d":"o","\u1e4f":"o","\u014d":"o","\u1e51":"o","\u1e53":"o","\u014f":"o","\u022f":"o","\u0231":"o","\xf6":"o","\u022b":"o","\u1ecf":"o","\u0151":"o","\u01d2":"o","\u020d":"o","\u020f":"o","\u01a1":"o","\u1edd":"o","\u1edb":"o","\u1ee1":"o","\u1edf":"o","\u1ee3":"o","\u1ecd":"o","\u1ed9":"o","\u01eb":"o","\u01ed":"o","\xf8":"o","\u01ff":"o","\u0254":"o","\ua74b":"o","\ua74d":"o","\u0275":"o","\u01a3":"oi","\u0223":"ou","\ua74f":"oo","\u24df":"p","\uff50":"p","\u1e55":"p","\u1e57":"p","\u01a5":"p","\u1d7d":"p","\ua751":"p","\ua753":"p","\ua755":"p","\u24e0":"q","\uff51":"q","\u024b":"q","\ua757":"q","\ua759":"q","\u24e1":"r","\uff52":"r","\u0155":"r","\u1e59":"r","\u0159":"r","\u0211":"r","\u0213":"r","\u1e5b":"r","\u1e5d":"r","\u0157":"r","\u1e5f":"r","\u024d":"r","\u027d":"r","\ua75b":"r","\ua7a7":"r","\ua783":"r","\u24e2":"s","\uff53":"s","\xdf":"s","\u015b":"s","\u1e65":"s","\u015d":"s","\u1e61":"s","\u0161":"s","\u1e67":"s","\u1e63":"s","\u1e69":"s","\u0219":"s","\u015f":"s","\u023f":"s","\ua7a9":"s","\ua785":"s","\u1e9b":"s","\u24e3":"t","\uff54":"t","\u1e6b":"t","\u1e97":"t","\u0165":"t","\u1e6d":"t","\u021b":"t","\u0163":"t","\u1e71":"t","\u1e6f":"t","\u0167":"t","\u01ad":"t","\u0288":"t","\u2c66":"t","\ua787":"t","\ua729":"tz","\u24e4":"u","\uff55":"u","\xf9":"u","\xfa":"u","\xfb":"u","\u0169":"u","\u1e79":"u","\u016b":"u","\u1e7b":"u","\u016d":"u","\xfc":"u","\u01dc":"u","\u01d8":"u","\u01d6":"u","\u01da":"u","\u1ee7":"u","\u016f":"u","\u0171":"u","\u01d4":"u","\u0215":"u","\u0217":"u","\u01b0":"u","\u1eeb":"u","\u1ee9":"u","\u1eef":"u","\u1eed":"u","\u1ef1":"u","\u1ee5":"u","\u1e73":"u","\u0173":"u","\u1e77":"u","\u1e75":"u","\u0289":"u","\u24e5":"v","\uff56":"v","\u1e7d":"v","\u1e7f":"v","\u028b":"v","\ua75f":"v","\u028c":"v","\ua761":"vy","\u24e6":"w","\uff57":"w","\u1e81":"w","\u1e83":"w","\u0175":"w","\u1e87":"w","\u1e85":"w","\u1e98":"w","\u1e89":"w","\u2c73":"w","\u24e7":"x","\uff58":"x","\u1e8b":"x","\u1e8d":"x","\u24e8":"y","\uff59":"y","\u1ef3":"y","\xfd":"y","\u0177":"y","\u1ef9":"y","\u0233":"y","\u1e8f":"y","\xff":"y","\u1ef7":"y","\u1e99":"y","\u1ef5":"y","\u01b4":"y","\u024f":"y","\u1eff":"y","\u24e9":"z","\uff5a":"z","\u017a":"z","\u1e91":"z","\u017c":"z","\u017e":"z","\u1e93":"z","\u1e95":"z","\u01b6":"z","\u0225":"z","\u0240":"z","\u2c6c":"z","\ua763":"z"};j=a(document),g=function(){var a=1;return function(){return a++}}(),j.on("mousemove",function(a){i.x=a.pageX,i.y=a.pageY}),d=N(Object,{bind:function(a){var b=this;return function(){a.apply(b,arguments)}},init:function(c){var d,e,h,i,f=".select2-results";this.opts=c=this.prepareOpts(c),this.id=c.id,c.element.data("select2")!==b&&null!==c.element.data("select2")&&c.element.data("select2").destroy(),this.container=this.createContainer(),this.containerId="s2id_"+(c.element.attr("id")||"autogen"+g()),this.containerSelector="#"+this.containerId.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1"),this.container.attr("id",this.containerId),this.body=w(function(){return c.element.closest("body")}),D(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.attr("style",c.element.attr("style")),this.container.css(K(c.containerCss)),this.container.addClass(K(c.containerCssClass)),this.elementTabIndex=this.opts.element.attr("tabindex"),this.opts.element.data("select2",this).attr("tabindex","-1").before(this.container),this.container.data("select2",this),this.dropdown=this.container.find(".select2-drop"),this.dropdown.addClass(K(c.dropdownCssClass)),this.dropdown.data("select2",this),D(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.results=d=this.container.find(f),this.search=e=this.container.find("input.select2-input"),this.queryCount=0,this.resultsPage=0,this.context=null,this.initContainer(),u(this.results),this.dropdown.on("mousemove-filtered touchstart touchmove touchend",f,this.bind(this.highlightUnderEvent)),x(80,this.results),this.dropdown.on("scroll-debounced",f,this.bind(this.loadMoreIfNeeded)),a(this.container).on("change",".select2-input",function(a){a.stopPropagation()}),a(this.dropdown).on("change",".select2-input",function(a){a.stopPropagation()}),a.fn.mousewheel&&d.mousewheel(function(a,b,c,e){var f=d.scrollTop();e>0&&0>=f-e?(d.scrollTop(0),A(a)):0>e&&d.get(0).scrollHeight-d.scrollTop()+e<=d.height()&&(d.scrollTop(d.get(0).scrollHeight-d.height()),A(a))}),t(e),e.on("keyup-change input paste",this.bind(this.updateResults)),e.on("focus",function(){e.addClass("select2-focused")}),e.on("blur",function(){e.removeClass("select2-focused")}),this.dropdown.on("mouseup",f,this.bind(function(b){a(b.target).closest(".select2-result-selectable").length>0&&(this.highlightUnderEvent(b),this.selectHighlighted(b))})),this.dropdown.on("click mouseup mousedown",function(a){a.stopPropagation()}),a.isFunction(this.opts.initSelection)&&(this.initSelection(),this.monitorSource()),null!==c.maximumInputLength&&this.search.attr("maxlength",c.maximumInputLength);var h=c.element.prop("disabled");h===b&&(h=!1),this.enable(!h);var i=c.element.prop("readonly");i===b&&(i=!1),this.readonly(i),k=k||p(),this.autofocus=c.element.prop("autofocus"),c.element.prop("autofocus",!1),this.autofocus&&this.focus(),this.nextSearchTerm=b},destroy:function(){var a=this.opts.element,c=a.data("select2");this.close(),this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),c!==b&&(c.container.remove(),c.dropdown.remove(),a.removeClass("select2-offscreen").removeData("select2").off(".select2").prop("autofocus",this.autofocus||!1),this.elementTabIndex?a.attr({tabindex:this.elementTabIndex}):a.removeAttr("tabindex"),a.show())},optionToData:function(a){return a.is("option")?{id:a.prop("value"),text:a.text(),element:a.get(),css:a.attr("class"),disabled:a.prop("disabled"),locked:q(a.attr("locked"),"locked")||q(a.data("locked"),!0)}:a.is("optgroup")?{text:a.attr("label"),children:[],element:a.get(),css:a.attr("class")}:void 0},prepareOpts:function(c){var d,e,f,g,h=this;if(d=c.element,"select"===d.get(0).tagName.toLowerCase()&&(this.select=e=c.element),e&&a.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in c)throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a element.")}),c=a.extend({},{populateResults:function(d,e,f){var g,l=this.opts.id;g=function(d,e,i){var j,k,m,n,o,p,q,r,s,t;for(d=c.sortResults(d,e,f),j=0,k=d.length;k>j;j+=1)m=d[j],o=m.disabled===!0,n=!o&&l(m)!==b,p=m.children&&m.children.length>0,q=a(" "),q.addClass("select2-results-dept-"+i),q.addClass("select2-result"),q.addClass(n?"select2-result-selectable":"select2-result-unselectable"),o&&q.addClass("select2-disabled"),p&&q.addClass("select2-result-with-children"),q.addClass(h.opts.formatResultCssClass(m)),r=a(document.createElement("div")),r.addClass("select2-result-label"),t=c.formatResult(m,r,f,h.opts.escapeMarkup),t!==b&&r.html(t),q.append(r),p&&(s=a(""),s.addClass("select2-result-sub"),g(m.children,s,i+1),q.append(s)),q.data("select2-data",m),e.append(q)},g(e,d,0)}},a.fn.select2.defaults,c),"function"!=typeof c.id&&(f=c.id,c.id=function(a){return a[f]}),a.isArray(c.element.data("select2Tags"))){if("tags"in c)throw"tags specified as both an attribute 'data-select2-tags' and in options of Select2 "+c.element.attr("id");c.tags=c.element.data("select2Tags")}if(e?(c.query=this.bind(function(a){var f,g,i,c={results:[],more:!1},e=a.term;i=function(b,c){var d;b.is("option")?a.matcher(e,b.text(),b)&&c.push(h.optionToData(b)):b.is("optgroup")&&(d=h.optionToData(b),b.children().each2(function(a,b){i(b,d.children)}),d.children.length>0&&c.push(d))},f=d.children(),this.getPlaceholder()!==b&&f.length>0&&(g=this.getPlaceholderOption(),g&&(f=f.not(g))),f.each2(function(a,b){i(b,c.results)}),a.callback(c)}),c.id=function(a){return a.id},c.formatResultCssClass=function(a){return a.css}):"query"in c||("ajax"in c?(g=c.element.data("ajax-url"),g&&g.length>0&&(c.ajax.url=g),c.query=G.call(c.element,c.ajax)):"data"in c?c.query=H(c.data):"tags"in c&&(c.query=I(c.tags),c.createSearchChoice===b&&(c.createSearchChoice=function(b){return{id:a.trim(b),text:a.trim(b)}}),c.initSelection===b&&(c.initSelection=function(b,d){var e=[];a(r(b.val(),c.separator)).each(function(){var b=this,d=this,f=c.tags;a.isFunction(f)&&(f=f()),a(f).each(function(){return q(this.id,b)?(d=this.text,!1):void 0}),e.push({id:b,text:d})}),d(e)}))),"function"!=typeof c.query)throw"query function not defined for Select2 "+c.element.attr("id");return c},monitorSource:function(){var c,a=this.opts.element;a.on("change.select2",this.bind(function(){this.opts.element.data("select2-change-triggered")!==!0&&this.initSelection()})),c=this.bind(function(){var d,f=a.prop("disabled");f===b&&(f=!1),this.enable(!f);var d=a.prop("readonly");d===b&&(d=!1),this.readonly(d),D(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.addClass(K(this.opts.containerCssClass)),D(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(K(this.opts.dropdownCssClass))}),a.on("propertychange.select2 DOMAttrModified.select2",c),this.mutationCallback===b&&(this.mutationCallback=function(a){a.forEach(c)}),"undefined"!=typeof WebKitMutationObserver&&(this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),this.propertyObserver=new WebKitMutationObserver(this.mutationCallback),this.propertyObserver.observe(a.get(0),{attributes:!0,subtree:!1}))},triggerSelect:function(b){var c=a.Event("select2-selecting",{val:this.id(b),object:b});return this.opts.element.trigger(c),!c.isDefaultPrevented()},triggerChange:function(b){b=b||{},b=a.extend({},b,{type:"change",val:this.val()}),this.opts.element.data("select2-change-triggered",!0),this.opts.element.trigger(b),this.opts.element.data("select2-change-triggered",!1),this.opts.element.click(),this.opts.blurOnChange&&this.opts.element.blur()},isInterfaceEnabled:function(){return this.enabledInterface===!0},enableInterface:function(){var a=this._enabled&&!this._readonly,b=!a;return a===this.enabledInterface?!1:(this.container.toggleClass("select2-container-disabled",b),this.close(),this.enabledInterface=a,!0)},enable:function(a){a===b&&(a=!0),this._enabled!==a&&(this._enabled=a,this.opts.element.prop("disabled",!a),this.enableInterface())},disable:function(){this.enable(!1)},readonly:function(a){return a===b&&(a=!1),this._readonly===a?!1:(this._readonly=a,this.opts.element.prop("readonly",a),this.enableInterface(),!0)},opened:function(){return this.container.hasClass("select2-dropdown-open")},positionDropdown:function(){var q,r,s,t,b=this.dropdown,c=this.container.offset(),d=this.container.outerHeight(!1),e=this.container.outerWidth(!1),f=b.outerHeight(!1),g=a(window).scrollLeft()+a(window).width(),h=a(window).scrollTop()+a(window).height(),i=c.top+d,j=c.left,l=h>=i+f,m=c.top-f>=this.body().scrollTop(),n=b.outerWidth(!1),o=g>=j+n,p=b.hasClass("select2-drop-above");this.opts.dropdownAutoWidth?(t=a(".select2-results",b)[0],b.addClass("select2-drop-auto-width"),b.css("width",""),n=b.outerWidth(!1)+(t.scrollHeight===t.clientHeight?0:k.width),n>e?e=n:n=e,o=g>=j+n):this.container.removeClass("select2-drop-auto-width"),"static"!==this.body().css("position")&&(q=this.body().offset(),i-=q.top,j-=q.left),p?(r=!0,!m&&l&&(r=!1)):(r=!1,!l&&m&&(r=!0)),o||(j=c.left+e-n),r?(i=c.top-f,this.container.addClass("select2-drop-above"),b.addClass("select2-drop-above")):(this.container.removeClass("select2-drop-above"),b.removeClass("select2-drop-above")),s=a.extend({top:i,left:j,width:e},K(this.opts.dropdownCss)),b.css(s)},shouldOpen:function(){var b;return this.opened()?!1:this._enabled===!1||this._readonly===!0?!1:(b=a.Event("select2-opening"),this.opts.element.trigger(b),!b.isDefaultPrevented())},clearDropdownAlignmentPreference:function(){this.container.removeClass("select2-drop-above"),this.dropdown.removeClass("select2-drop-above")},open:function(){return this.shouldOpen()?(this.opening(),!0):!1},opening:function(){var f,b=this.containerId,c="scroll."+b,d="resize."+b,e="orientationchange."+b;this.container.addClass("select2-dropdown-open").addClass("select2-container-active"),this.clearDropdownAlignmentPreference(),this.dropdown[0]!==this.body().children().last()[0]&&this.dropdown.detach().appendTo(this.body()),f=a("#select2-drop-mask"),0==f.length&&(f=a(document.createElement("div")),f.attr("id","select2-drop-mask").attr("class","select2-drop-mask"),f.hide(),f.appendTo(this.body()),f.on("mousedown touchstart click",function(b){var d,c=a("#select2-drop");c.length>0&&(d=c.data("select2"),d.opts.selectOnBlur&&d.selectHighlighted({noFocus:!0}),d.close({focus:!1}),b.preventDefault(),b.stopPropagation())})),this.dropdown.prev()[0]!==f[0]&&this.dropdown.before(f),a("#select2-drop").removeAttr("id"),this.dropdown.attr("id","select2-drop"),f.show(),this.positionDropdown(),this.dropdown.show(),this.positionDropdown(),this.dropdown.addClass("select2-drop-active");var h=this;this.container.parents().add(window).each(function(){a(this).on(d+" "+c+" "+e,function(){h.positionDropdown()})})},close:function(){if(this.opened()){var b=this.containerId,c="scroll."+b,d="resize."+b,e="orientationchange."+b;this.container.parents().add(window).each(function(){a(this).off(c).off(d).off(e)}),this.clearDropdownAlignmentPreference(),a("#select2-drop-mask").hide(),this.dropdown.removeAttr("id"),this.dropdown.hide(),this.container.removeClass("select2-dropdown-open"),this.results.empty(),this.clearSearch(),this.search.removeClass("select2-active"),this.opts.element.trigger(a.Event("select2-close"))}},externalSearch:function(a){this.open(),this.search.val(a),this.updateResults(!1)},clearSearch:function(){},getMaximumSelectionSize:function(){return K(this.opts.maximumSelectionSize)},ensureHighlightVisible:function(){var c,d,e,f,g,h,i,b=this.results;if(d=this.highlight(),!(0>d)){if(0==d)return b.scrollTop(0),void 0;c=this.findHighlightableChoices().find(".select2-result-label"),e=a(c[d]),f=e.offset().top+e.outerHeight(!0),d===c.length-1&&(i=b.find("li.select2-more-results"),i.length>0&&(f=i.offset().top+i.outerHeight(!0))),g=b.offset().top+b.outerHeight(!0),f>g&&b.scrollTop(b.scrollTop()+(f-g)),h=e.offset().top-b.offset().top,0>h&&"none"!=e.css("display")&&b.scrollTop(b.scrollTop()+h)}},findHighlightableChoices:function(){return this.results.find(".select2-result-selectable:not(.select2-selected):not(.select2-disabled)")},moveHighlight:function(b){for(var c=this.findHighlightableChoices(),d=this.highlight();d>-1&&d=c.length&&(b=c.length-1),0>b&&(b=0),this.removeHighlight(),d=a(c[b]),d.addClass("select2-highlighted"),this.ensureHighlightVisible(),e=d.data("select2-data"),e&&this.opts.element.trigger({type:"select2-highlight",val:this.id(e),choice:e}),void 0)},removeHighlight:function(){this.results.find(".select2-highlighted").removeClass("select2-highlighted")},countSelectableResults:function(){return this.findHighlightableChoices().length},highlightUnderEvent:function(b){var c=a(b.target).closest(".select2-result-selectable");if(c.length>0&&!c.is(".select2-highlighted")){var d=this.findHighlightableChoices();this.highlight(d.index(c))}else 0==c.length&&this.removeHighlight()},loadMoreIfNeeded:function(){var c,a=this.results,b=a.find("li.select2-more-results"),e=this.resultsPage+1,f=this,g=this.search.val(),h=this.context;0!==b.length&&(c=b.offset().top-a.offset().top-a.height(),c<=this.opts.loadMorePadding&&(b.addClass("select2-active"),this.opts.query({element:this.opts.element,term:g,page:e,context:h,matcher:this.opts.matcher,callback:this.bind(function(c){f.opened()&&(f.opts.populateResults.call(this,a,c.results,{term:g,page:e,context:h}),f.postprocessResults(c,!1,!1),c.more===!0?(b.detach().appendTo(a).text(f.opts.formatLoadMore(e+1)),window.setTimeout(function(){f.loadMoreIfNeeded()},10)):b.remove(),f.positionDropdown(),f.resultsPage=e,f.context=c.context,this.opts.element.trigger({type:"select2-loaded",items:c}))})})))},tokenize:function(){},updateResults:function(c){function m(){d.removeClass("select2-active"),h.positionDropdown()}function n(a){e.html(a),m()}var g,i,l,d=this.search,e=this.results,f=this.opts,h=this,j=d.val(),k=a.data(this.container,"select2-last-term");if((c===!0||!k||!q(j,k))&&(a.data(this.container,"select2-last-term",j),c===!0||this.showSearchInput!==!1&&this.opened())){l=++this.queryCount;var o=this.getMaximumSelectionSize();if(o>=1&&(g=this.data(),a.isArray(g)&&g.length>=o&&J(f.formatSelectionTooBig,"formatSelectionTooBig")))return n(""+f.formatSelectionTooBig(o)+" "),void 0;if(d.val().length"+f.formatInputTooShort(d.val(),f.minimumInputLength)+""):n(""),c&&this.showSearch&&this.showSearch(!0),void 0;if(f.maximumInputLength&&d.val().length>f.maximumInputLength)return J(f.formatInputTooLong,"formatInputTooLong")?n(""+f.formatInputTooLong(d.val(),f.maximumInputLength)+" "):n(""),void 0;
-f.formatSearching&&0===this.findHighlightableChoices().length&&n(""+f.formatSearching()+" "),d.addClass("select2-active"),this.removeHighlight(),i=this.tokenize(),i!=b&&null!=i&&d.val(i),this.resultsPage=1,f.query({element:f.element,term:d.val(),page:this.resultsPage,context:null,matcher:f.matcher,callback:this.bind(function(g){var i;if(l==this.queryCount){if(!this.opened())return this.search.removeClass("select2-active"),void 0;if(this.context=g.context===b?null:g.context,this.opts.createSearchChoice&&""!==d.val()&&(i=this.opts.createSearchChoice.call(h,d.val(),g.results),i!==b&&null!==i&&h.id(i)!==b&&null!==h.id(i)&&0===a(g.results).filter(function(){return q(h.id(this),h.id(i))}).length&&g.results.unshift(i)),0===g.results.length&&J(f.formatNoMatches,"formatNoMatches"))return n(""+f.formatNoMatches(d.val())+" "),void 0;e.empty(),h.opts.populateResults.call(this,e,g.results,{term:d.val(),page:this.resultsPage,context:null}),g.more===!0&&J(f.formatLoadMore,"formatLoadMore")&&(e.append(""+h.opts.escapeMarkup(f.formatLoadMore(this.resultsPage))+" "),window.setTimeout(function(){h.loadMoreIfNeeded()},10)),this.postprocessResults(g,c),m(),this.opts.element.trigger({type:"select2-loaded",items:g})}})})}},cancel:function(){this.close()},blur:function(){this.opts.selectOnBlur&&this.selectHighlighted({noFocus:!0}),this.close(),this.container.removeClass("select2-container-active"),this.search[0]===document.activeElement&&this.search.blur(),this.clearSearch(),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")},focusSearch:function(){y(this.search)},selectHighlighted:function(a){var b=this.highlight(),c=this.results.find(".select2-highlighted"),d=c.closest(".select2-result").data("select2-data");d?(this.highlight(b),this.onSelect(d,a)):a&&a.noFocus&&this.close()},getPlaceholder:function(){var a;return this.opts.element.attr("placeholder")||this.opts.element.attr("data-placeholder")||this.opts.element.data("placeholder")||this.opts.placeholder||((a=this.getPlaceholderOption())!==b?a.text():b)},getPlaceholderOption:function(){if(this.select){var a=this.select.children().first();if(this.opts.placeholderOption!==b)return"first"===this.opts.placeholderOption&&a||"function"==typeof this.opts.placeholderOption&&this.opts.placeholderOption(this.select);if(""===a.text()&&""===a.val())return a}},initContainerWidth:function(){function c(){var c,d,e,f,g;if("off"===this.opts.width)return null;if("element"===this.opts.width)return 0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px";if("copy"===this.opts.width||"resolve"===this.opts.width){if(c=this.opts.element.attr("style"),c!==b)for(d=c.split(";"),f=0,g=d.length;g>f;f+=1)if(e=d[f].replace(/\s/g,"").match(/[^-]width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i),null!==e&&e.length>=1)return e[1];return"resolve"===this.opts.width?(c=this.opts.element.css("width"),c.indexOf("%")>0?c:0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px"):null}return a.isFunction(this.opts.width)?this.opts.width():this.opts.width}var d=c.call(this);null!==d&&this.container.css("width",d)}}),e=N(d,{createContainer:function(){var b=a(document.createElement("div")).attr({"class":"select2-container"}).html([""," "," "," "," ",""].join(""));return b},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.focusser.prop("disabled",!this.isInterfaceEnabled())},opening:function(){var c,d,e;this.opts.minimumResultsForSearch>=0&&this.showSearch(!0),this.parent.opening.apply(this,arguments),this.showSearchInput!==!1&&this.search.val(this.focusser.val()),this.search.focus(),c=this.search.get(0),c.createTextRange?(d=c.createTextRange(),d.collapse(!1),d.select()):c.setSelectionRange&&(e=this.search.val().length,c.setSelectionRange(e,e)),""===this.search.val()&&this.nextSearchTerm!=b&&(this.search.val(this.nextSearchTerm),this.search.select()),this.focusser.prop("disabled",!0).val(""),this.updateResults(!0),this.opts.element.trigger(a.Event("select2-open"))},close:function(a){this.opened()&&(this.parent.close.apply(this,arguments),a=a||{focus:!0},this.focusser.removeAttr("disabled"),a.focus&&this.focusser.focus())},focus:function(){this.opened()?this.close():(this.focusser.removeAttr("disabled"),this.focusser.focus())},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments),this.focusser.removeAttr("disabled"),this.focusser.focus()},destroy:function(){a("label[for='"+this.focusser.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments)},initContainer:function(){var b,d=this.container,e=this.dropdown;this.opts.minimumResultsForSearch<0?this.showSearch(!1):this.showSearch(!0),this.selection=b=d.find(".select2-choice"),this.focusser=d.find(".select2-focusser"),this.focusser.attr("id","s2id_autogen"+g()),a("label[for='"+this.opts.element.attr("id")+"']").attr("for",this.focusser.attr("id")),this.focusser.attr("tabindex",this.elementTabIndex),this.search.on("keydown",this.bind(function(a){if(this.isInterfaceEnabled()){if(a.which===c.PAGE_UP||a.which===c.PAGE_DOWN)return A(a),void 0;switch(a.which){case c.UP:case c.DOWN:return this.moveHighlight(a.which===c.UP?-1:1),A(a),void 0;case c.ENTER:return this.selectHighlighted(),A(a),void 0;case c.TAB:return this.opts.selectOnBlur&&this.selectHighlighted({noFocus:!0}),void 0;case c.ESC:return this.cancel(a),A(a),void 0}}})),this.search.on("blur",this.bind(function(){document.activeElement===this.body().get(0)&&window.setTimeout(this.bind(function(){this.search.focus()}),0)})),this.focusser.on("keydown",this.bind(function(a){if(this.isInterfaceEnabled()&&a.which!==c.TAB&&!c.isControl(a)&&!c.isFunctionKey(a)&&a.which!==c.ESC){if(this.opts.openOnEnter===!1&&a.which===c.ENTER)return A(a),void 0;if(a.which==c.DOWN||a.which==c.UP||a.which==c.ENTER&&this.opts.openOnEnter){if(a.altKey||a.ctrlKey||a.shiftKey||a.metaKey)return;return this.open(),A(a),void 0}return a.which==c.DELETE||a.which==c.BACKSPACE?(this.opts.allowClear&&this.clear(),A(a),void 0):void 0}})),t(this.focusser),this.focusser.on("keyup-change input",this.bind(function(a){if(this.opts.minimumResultsForSearch>=0){if(a.stopPropagation(),this.opened())return;this.open()}})),b.on("mousedown","abbr",this.bind(function(a){this.isInterfaceEnabled()&&(this.clear(),B(a),this.close(),this.selection.focus())})),b.on("mousedown",this.bind(function(b){this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.opened()?this.close():this.isInterfaceEnabled()&&this.open(),A(b)})),e.on("mousedown",this.bind(function(){this.search.focus()})),b.on("focus",this.bind(function(a){A(a)})),this.focusser.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active")})).on("blur",this.bind(function(){this.opened()||(this.container.removeClass("select2-container-active"),this.opts.element.trigger(a.Event("select2-blur")))})),this.search.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active")})),this.initContainerWidth(),this.opts.element.addClass("select2-offscreen"),this.setPlaceholder()},clear:function(a){var b=this.selection.data("select2-data");if(b){var c=this.getPlaceholderOption();this.opts.element.val(c?c.val():""),this.selection.find(".select2-chosen").empty(),this.selection.removeData("select2-data"),this.setPlaceholder(),a!==!1&&(this.opts.element.trigger({type:"select2-removed",val:this.id(b),choice:b}),this.triggerChange({removed:b}))}},initSelection:function(){if(this.isPlaceholderOptionSelected())this.updateSelection(null),this.close(),this.setPlaceholder();else{var c=this;this.opts.initSelection.call(null,this.opts.element,function(a){a!==b&&null!==a&&(c.updateSelection(a),c.close(),c.setPlaceholder())})}},isPlaceholderOptionSelected:function(){var a;return this.opts.placeholder?(a=this.getPlaceholderOption())!==b&&a.is(":selected")||""===this.opts.element.val()||this.opts.element.val()===b||null===this.opts.element.val():!1},prepareOpts:function(){var b=this.parent.prepareOpts.apply(this,arguments),c=this;return"select"===b.element.get(0).tagName.toLowerCase()?b.initSelection=function(a,b){var d=a.find(":selected");b(c.optionToData(d))}:"data"in b&&(b.initSelection=b.initSelection||function(c,d){var e=c.val(),f=null;b.query({matcher:function(a,c,d){var g=q(e,b.id(d));return g&&(f=d),g},callback:a.isFunction(d)?function(){d(f)}:a.noop})}),b},getPlaceholder:function(){return this.select&&this.getPlaceholderOption()===b?b:this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var a=this.getPlaceholder();if(this.isPlaceholderOptionSelected()&&a!==b){if(this.select&&this.getPlaceholderOption()===b)return;this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(a)),this.selection.addClass("select2-default"),this.container.removeClass("select2-allowclear")}},postprocessResults:function(a,b,c){var d=0,e=this;if(this.findHighlightableChoices().each2(function(a,b){return q(e.id(b.data("select2-data")),e.opts.element.val())?(d=a,!1):void 0}),c!==!1&&(b===!0&&d>=0?this.highlight(d):this.highlight(0)),b===!0){var g=this.opts.minimumResultsForSearch;g>=0&&this.showSearch(L(a.results)>=g)}},showSearch:function(b){this.showSearchInput!==b&&(this.showSearchInput=b,this.dropdown.find(".select2-search").toggleClass("select2-search-hidden",!b),this.dropdown.find(".select2-search").toggleClass("select2-offscreen",!b),a(this.dropdown,this.container).toggleClass("select2-with-searchbox",b))},onSelect:function(a,b){if(this.triggerSelect(a)){var c=this.opts.element.val(),d=this.data();this.opts.element.val(this.id(a)),this.updateSelection(a),this.opts.element.trigger({type:"select2-selected",val:this.id(a),choice:a}),this.nextSearchTerm=this.opts.nextSearchTerm(a,this.search.val()),this.close(),b&&b.noFocus||this.selection.focus(),q(c,this.id(a))||this.triggerChange({added:a,removed:d})}},updateSelection:function(a){var d,e,c=this.selection.find(".select2-chosen");this.selection.data("select2-data",a),c.empty(),null!==a&&(d=this.opts.formatSelection(a,c,this.opts.escapeMarkup)),d!==b&&c.append(d),e=this.opts.formatSelectionCssClass(a,c),e!==b&&c.addClass(e),this.selection.removeClass("select2-default"),this.opts.allowClear&&this.getPlaceholder()!==b&&this.container.addClass("select2-allowclear")},val:function(){var a,c=!1,d=null,e=this,f=this.data();if(0===arguments.length)return this.opts.element.val();if(a=arguments[0],arguments.length>1&&(c=arguments[1]),this.select)this.select.val(a).find(":selected").each2(function(a,b){return d=e.optionToData(b),!1}),this.updateSelection(d),this.setPlaceholder(),c&&this.triggerChange({added:d,removed:f});else{if(!a&&0!==a)return this.clear(c),void 0;if(this.opts.initSelection===b)throw new Error("cannot call val() if initSelection() is not defined");this.opts.element.val(a),this.opts.initSelection(this.opts.element,function(a){e.opts.element.val(a?e.id(a):""),e.updateSelection(a),e.setPlaceholder(),c&&e.triggerChange({added:a,removed:f})})}},clearSearch:function(){this.search.val(""),this.focusser.val("")},data:function(a){var c,d=!1;return 0===arguments.length?(c=this.selection.data("select2-data"),c==b&&(c=null),c):(arguments.length>1&&(d=arguments[1]),a?(c=this.data(),this.opts.element.val(a?this.id(a):""),this.updateSelection(a),d&&this.triggerChange({added:a,removed:c})):this.clear(d),void 0)}}),f=N(d,{createContainer:function(){var b=a(document.createElement("div")).attr({"class":"select2-container select2-container-multi"}).html(["",""].join(""));return b},prepareOpts:function(){var b=this.parent.prepareOpts.apply(this,arguments),c=this;return"select"===b.element.get(0).tagName.toLowerCase()?b.initSelection=function(a,b){var d=[];a.find(":selected").each2(function(a,b){d.push(c.optionToData(b))}),b(d)}:"data"in b&&(b.initSelection=b.initSelection||function(c,d){var e=r(c.val(),b.separator),f=[];b.query({matcher:function(c,d,g){var h=a.grep(e,function(a){return q(a,b.id(g))}).length;return h&&f.push(g),h},callback:a.isFunction(d)?function(){for(var a=[],c=0;c0||(this.selectChoice(null),this.clearPlaceholder(),this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.open(),this.focusSearch(),b.preventDefault()))})),this.container.on("focus",b,this.bind(function(){this.isInterfaceEnabled()&&(this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"),this.clearPlaceholder())})),this.initContainerWidth(),this.opts.element.addClass("select2-offscreen"),this.clearSearch()},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.search.prop("disabled",!this.isInterfaceEnabled())},initSelection:function(){if(""===this.opts.element.val()&&""===this.opts.element.text()&&(this.updateSelection([]),this.close(),this.clearSearch()),this.select||""!==this.opts.element.val()){var c=this;this.opts.initSelection.call(null,this.opts.element,function(a){a!==b&&null!==a&&(c.updateSelection(a),c.close(),c.clearSearch())})}},clearSearch:function(){var a=this.getPlaceholder(),c=this.getMaxSearchWidth();a!==b&&0===this.getVal().length&&this.search.hasClass("select2-focused")===!1?(this.search.val(a).addClass("select2-default"),this.search.width(c>0?c:this.container.css("width"))):this.search.val("").width(10)},clearPlaceholder:function(){this.search.hasClass("select2-default")&&this.search.val("").removeClass("select2-default")},opening:function(){this.clearPlaceholder(),this.resizeSearch(),this.parent.opening.apply(this,arguments),this.focusSearch(),this.updateResults(!0),this.search.focus(),this.opts.element.trigger(a.Event("select2-open"))},close:function(){this.opened()&&this.parent.close.apply(this,arguments)},focus:function(){this.close(),this.search.focus()},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(b){var c=[],d=[],e=this;a(b).each(function(){o(e.id(this),c)<0&&(c.push(e.id(this)),d.push(this))}),b=d,this.selection.find(".select2-search-choice").remove(),a(b).each(function(){e.addSelectedChoice(this)}),e.postprocessResults()},tokenize:function(){var a=this.search.val();a=this.opts.tokenizer.call(this,a,this.data(),this.bind(this.onSelect),this.opts),null!=a&&a!=b&&(this.search.val(a),a.length>0&&this.open())},onSelect:function(a,b){this.triggerSelect(a)&&(this.addSelectedChoice(a),this.opts.element.trigger({type:"selected",val:this.id(a),choice:a}),(this.select||!this.opts.closeOnSelect)&&this.postprocessResults(a,!1,this.opts.closeOnSelect===!0),this.opts.closeOnSelect?(this.close(),this.search.width(10)):this.countSelectableResults()>0?(this.search.width(10),this.resizeSearch(),this.getMaximumSelectionSize()>0&&this.val().length>=this.getMaximumSelectionSize()&&this.updateResults(!0),this.positionDropdown()):(this.close(),this.search.width(10)),this.triggerChange({added:a}),b&&b.noFocus||this.focusSearch())},cancel:function(){this.close(),this.focusSearch()},addSelectedChoice:function(c){var j,k,d=!c.locked,e=a("
"),f=a("
"),g=d?e:f,h=this.id(c),i=this.getVal();j=this.opts.formatSelection(c,g.find("div"),this.opts.escapeMarkup),j!=b&&g.find("div").replaceWith(""+j+"
"),k=this.opts.formatSelectionCssClass(c,g.find("div")),k!=b&&g.addClass(k),d&&g.find(".select2-search-choice-close").on("mousedown",A).on("click dblclick",this.bind(function(b){this.isInterfaceEnabled()&&(a(b.target).closest(".select2-search-choice").fadeOut("fast",this.bind(function(){this.unselect(a(b.target)),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus"),this.close(),this.focusSearch()})).dequeue(),A(b))})).on("focus",this.bind(function(){this.isInterfaceEnabled()&&(this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"))})),g.data("select2-data",c),g.insertBefore(this.searchContainer),i.push(h),this.setVal(i)},unselect:function(a){var c,d,b=this.getVal();if(a=a.closest(".select2-search-choice"),0===a.length)throw"Invalid argument: "+a+". Must be .select2-search-choice";c=a.data("select2-data"),c&&(d=o(this.id(c),b),d>=0&&(b.splice(d,1),this.setVal(b),this.select&&this.postprocessResults()),a.remove(),this.opts.element.trigger({type:"removed",val:this.id(c),choice:c}),this.triggerChange({removed:c}))},postprocessResults:function(a,b,c){var d=this.getVal(),e=this.results.find(".select2-result"),f=this.results.find(".select2-result-with-children"),g=this;e.each2(function(a,b){var c=g.id(b.data("select2-data"));o(c,d)>=0&&(b.addClass("select2-selected"),b.find(".select2-result-selectable").addClass("select2-selected"))}),f.each2(function(a,b){b.is(".select2-result-selectable")||0!==b.find(".select2-result-selectable:not(.select2-selected)").length||b.addClass("select2-selected")}),-1==this.highlight()&&c!==!1&&g.highlight(0),!this.opts.createSearchChoice&&!e.filter(".select2-result:not(.select2-selected)").length>0&&(!a||a&&!a.more&&0===this.results.find(".select2-no-results").length)&&J(g.opts.formatNoMatches,"formatNoMatches")&&this.results.append(""+g.opts.formatNoMatches(g.search.val())+" ")},getMaxSearchWidth:function(){return this.selection.width()-s(this.search)},resizeSearch:function(){var a,b,c,d,e,f=s(this.search);a=C(this.search)+10,b=this.search.offset().left,c=this.selection.width(),d=this.selection.offset().left,e=c-(b-d)-f,a>e&&(e=c-f),40>e&&(e=c-f),0>=e&&(e=a),this.search.width(e)},getVal:function(){var a;return this.select?(a=this.select.val(),null===a?[]:a):(a=this.opts.element.val(),r(a,this.opts.separator))},setVal:function(b){var c;this.select?this.select.val(b):(c=[],a(b).each(function(){o(this,c)<0&&c.push(this)}),this.opts.element.val(0===c.length?"":c.join(this.opts.separator)))},buildChangeDetails:function(a,b){for(var b=b.slice(0),a=a.slice(0),c=0;c. Attach to instead.");this.search.width(0),this.searchContainer.hide()},onSortEnd:function(){var b=[],c=this;this.searchContainer.show(),this.searchContainer.appendTo(this.searchContainer.parent()),this.resizeSearch(),this.selection.find(".select2-search-choice").each(function(){b.push(c.opts.id(a(this).data("select2-data")))}),this.setVal(b),this.triggerChange()},data:function(b,c){var e,f,d=this;return 0===arguments.length?this.selection.find(".select2-search-choice").map(function(){return a(this).data("select2-data")}).get():(f=this.data(),b||(b=[]),e=a.map(b,function(a){return d.opts.id(a)}),this.setVal(e),this.updateSelection(b),this.clearSearch(),c&&this.triggerChange(this.buildChangeDetails(f,this.data())),void 0)}}),a.fn.select2=function(){var d,g,h,i,j,c=Array.prototype.slice.call(arguments,0),k=["val","destroy","opened","open","close","focus","isFocused","container","dropdown","onSortStart","onSortEnd","enable","disable","readonly","positionDropdown","data","search"],l=["opened","isFocused","container","dropdown"],m=["val","data"],n={search:"externalSearch"};return this.each(function(){if(0===c.length||"object"==typeof c[0])d=0===c.length?{}:a.extend({},c[0]),d.element=a(this),"select"===d.element.get(0).tagName.toLowerCase()?j=d.element.prop("multiple"):(j=d.multiple||!1,"tags"in d&&(d.multiple=j=!0)),g=j?new f:new e,g.init(d);else{if("string"!=typeof c[0])throw"Invalid arguments to select2 plugin: "+c;if(o(c[0],k)<0)throw"Unknown method: "+c[0];if(i=b,g=a(this).data("select2"),g===b)return;if(h=c[0],"container"===h?i=g.container:"dropdown"===h?i=g.dropdown:(n[h]&&(h=n[h]),i=g[h].apply(g,c.slice(1))),o(c[0],l)>=0||o(c[0],m)&&1==c.length)return!1}}),i===b?this:i},a.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:!0,openOnEnter:!0,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(a,b,c,d){var e=[];return E(a.text,c.term,e,d),e.join("")},formatSelection:function(a,c,d){return a?d(a.text):b},sortResults:function(a){return a},formatResultCssClass:function(){return b},formatSelectionCssClass:function(){return b},formatNoMatches:function(){return"No matches found"},formatInputTooShort:function(a,b){var c=b-a.length;return"Please enter "+c+" more character"+(1==c?"":"s")},formatInputTooLong:function(a,b){var c=a.length-b;return"Please delete "+c+" character"+(1==c?"":"s")},formatSelectionTooBig:function(a){return"You can only select "+a+" item"+(1==a?"":"s")},formatLoadMore:function(){return"Loading more results..."},formatSearching:function(){return"Searching..."},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(a){return a.id},matcher:function(a,b){return n(""+b).toUpperCase().indexOf(n(""+a).toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:M,escapeMarkup:F,blurOnChange:!1,selectOnBlur:!1,adaptContainerCssClass:function(a){return a},adaptDropdownCssClass:function(){return null},nextSearchTerm:function(){return b}},a.fn.select2.ajaxDefaults={transport:a.ajax,params:{type:"GET",cache:!1,dataType:"json"}},window.Select2={query:{ajax:G,local:H,tags:I},util:{debounce:v,markMatch:E,escapeMarkup:F,stripDiacritics:n},"class":{"abstract":d,single:e,multi:f}}}}(jQuery);
\ No newline at end of file
+/*! Select2 4.0.3 | https://github.com/select2/select2/blob/master/LICENSE.md */!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b=function(){if(a&&a.fn&&a.fn.select2&&a.fn.select2.amd)var b=a.fn.select2.amd;var b;return function(){if(!b||!b.requirejs){b?c=b:b={};var a,c,d;!function(b){function e(a,b){return u.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=s.map,p=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(a=a.split("/"),g=a.length-1,s.nodeIdCompat&&w.test(a[g])&&(a[g]=a[g].replace(w,"")),a=n.slice(0,n.length-1).concat(a),k=0;k0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||p)&&o){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&p&&p[d]&&(i=p[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,c){return function(){var d=v.call(arguments,0);return"string"!=typeof d[0]&&1===d.length&&d.push(null),n.apply(b,d.concat([a,c]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){q[a]=b}}function j(a){if(e(r,a)){var c=r[a];delete r[a],t[a]=!0,m.apply(b,c)}if(!e(q,a)&&!e(t,a))throw new Error("No "+a);return q[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return function(){return s&&s.config&&s.config[a]||{}}}var m,n,o,p,q={},r={},s={},t={},u=Object.prototype.hasOwnProperty,v=[].slice,w=/\.js$/;o=function(a,b){var c,d=k(a),e=d[0];return a=d[1],e&&(e=f(e,b),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(b)):f(a,b):(a=f(a,b),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},p={require:function(a){return g(a)},exports:function(a){var b=q[a];return"undefined"!=typeof b?b:q[a]={}},module:function(a){return{id:a,uri:"",exports:q[a],config:l(a)}}},m=function(a,c,d,f){var h,k,l,m,n,s,u=[],v=typeof d;if(f=f||a,"undefined"===v||"function"===v){for(c=!c.length&&d.length?["require","exports","module"]:c,n=0;n0&&(b.call(arguments,a.prototype.constructor),e=c.prototype.constructor),e.apply(this,arguments)}function e(){this.constructor=d}var f=b(c),g=b(a);c.displayName=a.displayName,d.prototype=new e;for(var h=0;hc;c++)a[c].apply(this,b)},c.Observable=d,c.generateChars=function(a){for(var b="",c=0;a>c;c++){var d=Math.floor(36*Math.random());b+=d.toString(36)}return b},c.bind=function(a,b){return function(){a.apply(b,arguments)}},c._convertData=function(a){for(var b in a){var c=b.split("-"),d=a;if(1!==c.length){for(var e=0;e":">",'"':""","'":"'","/":"/"};return"string"!=typeof a?a:String(a).replace(/[&<>"'\/\\]/g,function(a){return b[a]})},c.appendMany=function(b,c){if("1.7"===a.fn.jquery.substr(0,3)){var d=a();a.map(c,function(a){d=d.add(a)}),c=d}b.append(c)},c}),b.define("select2/results",["jquery","./utils"],function(a,b){function c(a,b,d){this.$element=a,this.data=d,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('');return this.options.get("multiple")&&b.attr("aria-multiselectable","true"),this.$results=b,b},c.prototype.clear=function(){this.$results.empty()},c.prototype.displayMessage=function(b){var c=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var d=a(' '),e=this.options.get("translations").get(b.message);d.append(c(e(b.args))),d[0].className+=" select2-results__message",this.$results.append(d)},c.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},c.prototype.append=function(a){this.hideLoading();var b=[];if(null==a.results||0===a.results.length)return void(0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"}));a.results=this.sort(a.results);for(var c=0;c0?b.first().trigger("mouseenter"):a.first().trigger("mouseenter"),this.ensureHighlightVisible()},c.prototype.setClasses=function(){var b=this;this.data.current(function(c){var d=a.map(c,function(a){return a.id.toString()}),e=b.$results.find(".select2-results__option[aria-selected]");e.each(function(){var b=a(this),c=a.data(this,"data"),e=""+c.id;null!=c.element&&c.element.selected||null==c.element&&a.inArray(e,d)>-1?b.attr("aria-selected","true"):b.attr("aria-selected","false")})})},c.prototype.showLoading=function(a){this.hideLoading();var b=this.options.get("translations").get("searching"),c={disabled:!0,loading:!0,text:b(a)},d=this.option(c);d.className+=" loading-results",this.$results.prepend(d)},c.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},c.prototype.option=function(b){var c=document.createElement("li");c.className="select2-results__option";var d={role:"treeitem","aria-selected":"false"};b.disabled&&(delete d["aria-selected"],d["aria-disabled"]="true"),null==b.id&&delete d["aria-selected"],null!=b._resultId&&(c.id=b._resultId),b.title&&(c.title=b.title),b.children&&(d.role="group",d["aria-label"]=b.text,delete d["aria-selected"]);for(var e in d){var f=d[e];c.setAttribute(e,f)}if(b.children){var g=a(c),h=document.createElement("strong");h.className="select2-results__group";a(h);this.template(b,h);for(var i=[],j=0;j",{"class":"select2-results__options select2-results__options--nested"});m.append(i),g.append(h),g.append(m)}else this.template(b,c);return a.data(c,"data",b),c},c.prototype.bind=function(b,c){var d=this,e=b.id+"-results";this.$results.attr("id",e),b.on("results:all",function(a){d.clear(),d.append(a.data),b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("results:append",function(a){d.append(a.data),b.isOpen()&&d.setClasses()}),b.on("query",function(a){d.hideMessages(),d.showLoading(a)}),b.on("select",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("unselect",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("open",function(){d.$results.attr("aria-expanded","true"),d.$results.attr("aria-hidden","false"),d.setClasses(),d.ensureHighlightVisible()}),b.on("close",function(){d.$results.attr("aria-expanded","false"),d.$results.attr("aria-hidden","true"),d.$results.removeAttr("aria-activedescendant")}),b.on("results:toggle",function(){var a=d.getHighlightedResults();0!==a.length&&a.trigger("mouseup")}),b.on("results:select",function(){var a=d.getHighlightedResults();if(0!==a.length){var b=a.data("data");"true"==a.attr("aria-selected")?d.trigger("close",{}):d.trigger("select",{data:b})}}),b.on("results:previous",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a);if(0!==c){var e=c-1;0===a.length&&(e=0);var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top,h=f.offset().top,i=d.$results.scrollTop()+(h-g);0===e?d.$results.scrollTop(0):0>h-g&&d.$results.scrollTop(i)}}),b.on("results:next",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a),e=c+1;if(!(e>=b.length)){var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top+d.$results.outerHeight(!1),h=f.offset().top+f.outerHeight(!1),i=d.$results.scrollTop()+h-g;0===e?d.$results.scrollTop(0):h>g&&d.$results.scrollTop(i)}}),b.on("results:focus",function(a){a.element.addClass("select2-results__option--highlighted")}),b.on("results:message",function(a){d.displayMessage(a)}),a.fn.mousewheel&&this.$results.on("mousewheel",function(a){var b=d.$results.scrollTop(),c=d.$results.get(0).scrollHeight-b+a.deltaY,e=a.deltaY>0&&b-a.deltaY<=0,f=a.deltaY<0&&c<=d.$results.height();e?(d.$results.scrollTop(0),a.preventDefault(),a.stopPropagation()):f&&(d.$results.scrollTop(d.$results.get(0).scrollHeight-d.$results.height()),a.preventDefault(),a.stopPropagation())}),this.$results.on("mouseup",".select2-results__option[aria-selected]",function(b){var c=a(this),e=c.data("data");return"true"===c.attr("aria-selected")?void(d.options.get("multiple")?d.trigger("unselect",{originalEvent:b,data:e}):d.trigger("close",{})):void d.trigger("select",{originalEvent:b,data:e})}),this.$results.on("mouseenter",".select2-results__option[aria-selected]",function(b){var c=a(this).data("data");d.getHighlightedResults().removeClass("select2-results__option--highlighted"),d.trigger("results:focus",{data:c,element:a(this)})})},c.prototype.getHighlightedResults=function(){var a=this.$results.find(".select2-results__option--highlighted");return a},c.prototype.destroy=function(){this.$results.remove()},c.prototype.ensureHighlightVisible=function(){var a=this.getHighlightedResults();if(0!==a.length){var b=this.$results.find("[aria-selected]"),c=b.index(a),d=this.$results.offset().top,e=a.offset().top,f=this.$results.scrollTop()+(e-d),g=e-d;f-=2*a.outerHeight(!1),2>=c?this.$results.scrollTop(0):(g>this.$results.outerHeight()||0>g)&&this.$results.scrollTop(f)}},c.prototype.template=function(b,c){var d=this.options.get("templateResult"),e=this.options.get("escapeMarkup"),f=d(b,c);null==f?c.style.display="none":"string"==typeof f?c.innerHTML=e(f):a(c).append(f)},c}),b.define("select2/keys",[],function(){var a={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46};return a}),b.define("select2/selection/base",["jquery","../utils","../keys"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,b.Observable),d.prototype.render=function(){var b=a(' ');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),b.attr("title",this.$element.attr("title")),b.attr("tabindex",this._tabindex),this.$selection=b,b},d.prototype.bind=function(a,b){var d=this,e=(a.id+"-container",a.id+"-results");this.container=a,this.$selection.on("focus",function(a){d.trigger("focus",a)}),this.$selection.on("blur",function(a){d._handleBlur(a)}),this.$selection.on("keydown",function(a){d.trigger("keypress",a),a.which===c.SPACE&&a.preventDefault()}),a.on("results:focus",function(a){d.$selection.attr("aria-activedescendant",a.data._resultId)}),a.on("selection:update",function(a){d.update(a.data)}),a.on("open",function(){d.$selection.attr("aria-expanded","true"),d.$selection.attr("aria-owns",e),d._attachCloseHandler(a)}),a.on("close",function(){d.$selection.attr("aria-expanded","false"),d.$selection.removeAttr("aria-activedescendant"),d.$selection.removeAttr("aria-owns"),d.$selection.focus(),d._detachCloseHandler(a)}),a.on("enable",function(){d.$selection.attr("tabindex",d._tabindex)}),a.on("disable",function(){d.$selection.attr("tabindex","-1")})},d.prototype._handleBlur=function(b){var c=this;window.setTimeout(function(){document.activeElement==c.$selection[0]||a.contains(c.$selection[0],document.activeElement)||c.trigger("blur",b)},1)},d.prototype._attachCloseHandler=function(b){a(document.body).on("mousedown.select2."+b.id,function(b){var c=a(b.target),d=c.closest(".select2"),e=a(".select2.select2-container--open");e.each(function(){var b=a(this);if(this!=d[0]){var c=b.data("element");c.select2("close")}})})},d.prototype._detachCloseHandler=function(b){a(document.body).off("mousedown.select2."+b.id)},d.prototype.position=function(a,b){var c=b.find(".selection");c.append(a)},d.prototype.destroy=function(){this._detachCloseHandler(this.container)},d.prototype.update=function(a){throw new Error("The `update` method must be defined in child classes.")},d}),b.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(a,b,c,d){function e(){e.__super__.constructor.apply(this,arguments)}return c.Extend(e,b),e.prototype.render=function(){var a=e.__super__.render.call(this);return a.addClass("select2-selection--single"),a.html(' '),a},e.prototype.bind=function(a,b){var c=this;e.__super__.bind.apply(this,arguments);var d=a.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",d),this.$selection.attr("aria-labelledby",d),this.$selection.on("mousedown",function(a){1===a.which&&c.trigger("toggle",{originalEvent:a})}),this.$selection.on("focus",function(a){}),this.$selection.on("blur",function(a){}),a.on("focus",function(b){a.isOpen()||c.$selection.focus()}),a.on("selection:update",function(a){c.update(a.data)})},e.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},e.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},e.prototype.selectionContainer=function(){return a(" ")},e.prototype.update=function(a){if(0===a.length)return void this.clear();var b=a[0],c=this.$selection.find(".select2-selection__rendered"),d=this.display(b,c);c.empty().append(d),c.prop("title",b.title||b.text)},e}),b.define("select2/selection/multiple",["jquery","./base","../utils"],function(a,b,c){function d(a,b){d.__super__.constructor.apply(this,arguments)}return c.Extend(d,b),d.prototype.render=function(){var a=d.__super__.render.call(this);return a.addClass("select2-selection--multiple"),a.html(''),a},d.prototype.bind=function(b,c){var e=this;d.__super__.bind.apply(this,arguments),this.$selection.on("click",function(a){e.trigger("toggle",{originalEvent:a})}),this.$selection.on("click",".select2-selection__choice__remove",function(b){if(!e.options.get("disabled")){var c=a(this),d=c.parent(),f=d.data("data");e.trigger("unselect",{originalEvent:b,data:f})}})},d.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},d.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},d.prototype.selectionContainer=function(){var b=a('× ');return b},d.prototype.update=function(a){if(this.clear(),0!==a.length){for(var b=[],d=0;d1;if(d||c)return a.call(this,b);this.clear();var e=this.createPlaceholder(this.placeholder);this.$selection.find(".select2-selection__rendered").append(e)},b}),b.define("select2/selection/allowClear",["jquery","../keys"],function(a,b){function c(){}return c.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".select2-selection__clear",function(a){d._handleClear(a)}),b.on("keypress",function(a){d._handleKeyboardClear(a,b)})},c.prototype._handleClear=function(a,b){if(!this.options.get("disabled")){var c=this.$selection.find(".select2-selection__clear");if(0!==c.length){b.stopPropagation();for(var d=c.data("data"),e=0;e0||0===c.length)){var d=a('× ');d.data("data",c),this.$selection.find(".select2-selection__rendered").prepend(d)}},c}),b.define("select2/selection/search",["jquery","../utils","../keys"],function(a,b,c){function d(a,b,c){a.call(this,b,c)}return d.prototype.render=function(b){var c=a(' ');this.$searchContainer=c,this.$search=c.find("input");var d=b.call(this);return this._transferTabIndex(),d},d.prototype.bind=function(a,b,d){var e=this;a.call(this,b,d),b.on("open",function(){e.$search.trigger("focus")}),b.on("close",function(){e.$search.val(""),e.$search.removeAttr("aria-activedescendant"),e.$search.trigger("focus")}),b.on("enable",function(){e.$search.prop("disabled",!1),e._transferTabIndex()}),b.on("disable",function(){e.$search.prop("disabled",!0)}),b.on("focus",function(a){e.$search.trigger("focus")}),b.on("results:focus",function(a){e.$search.attr("aria-activedescendant",a.id)}),this.$selection.on("focusin",".select2-search--inline",function(a){e.trigger("focus",a)}),this.$selection.on("focusout",".select2-search--inline",function(a){e._handleBlur(a)}),this.$selection.on("keydown",".select2-search--inline",function(a){a.stopPropagation(),e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented();var b=a.which;if(b===c.BACKSPACE&&""===e.$search.val()){var d=e.$searchContainer.prev(".select2-selection__choice");if(d.length>0){var f=d.data("data");e.searchRemoveChoice(f),a.preventDefault()}}});var f=document.documentMode,g=f&&11>=f;this.$selection.on("input.searchcheck",".select2-search--inline",function(a){return g?void e.$selection.off("input.search input.searchcheck"):void e.$selection.off("keyup.search")}),this.$selection.on("keyup.search input.search",".select2-search--inline",function(a){if(g&&"input"===a.type)return void e.$selection.off("input.search input.searchcheck");var b=a.which;b!=c.SHIFT&&b!=c.CTRL&&b!=c.ALT&&b!=c.TAB&&e.handleSearch(a)})},d.prototype._transferTabIndex=function(a){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},d.prototype.createPlaceholder=function(a,b){this.$search.attr("placeholder",b.text)},d.prototype.update=function(a,b){var c=this.$search[0]==document.activeElement;this.$search.attr("placeholder",""),a.call(this,b),this.$selection.find(".select2-selection__rendered").append(this.$searchContainer),this.resizeSearch(),c&&this.$search.focus()},d.prototype.handleSearch=function(){if(this.resizeSearch(),!this._keyUpPrevented){var a=this.$search.val();this.trigger("query",{term:a})}this._keyUpPrevented=!1},d.prototype.searchRemoveChoice=function(a,b){this.trigger("unselect",{data:b}),this.$search.val(b.text),this.handleSearch()},d.prototype.resizeSearch=function(){this.$search.css("width","25px");var a="";if(""!==this.$search.attr("placeholder"))a=this.$selection.find(".select2-selection__rendered").innerWidth();else{var b=this.$search.val().length+1;a=.75*b+"em"}this.$search.css("width",a)},d}),b.define("select2/selection/eventRelay",["jquery"],function(a){function b(){}return b.prototype.bind=function(b,c,d){var e=this,f=["open","opening","close","closing","select","selecting","unselect","unselecting"],g=["opening","closing","selecting","unselecting"];b.call(this,c,d),c.on("*",function(b,c){if(-1!==a.inArray(b,f)){c=c||{};var d=a.Event("select2:"+b,{params:c});e.$element.trigger(d),-1!==a.inArray(b,g)&&(c.prevented=d.isDefaultPrevented())}})},b}),b.define("select2/translation",["jquery","require"],function(a,b){function c(a){this.dict=a||{}}return c.prototype.all=function(){return this.dict},c.prototype.get=function(a){return this.dict[a]},c.prototype.extend=function(b){this.dict=a.extend({},b.all(),this.dict)},c._cache={},c.loadPath=function(a){if(!(a in c._cache)){var d=b(a);c._cache[a]=d}return new c(c._cache[a])},c}),b.define("select2/diacritics",[],function(){var a={"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ω":"ω","ς":"σ"};return a}),b.define("select2/data/base",["../utils"],function(a){function b(a,c){b.__super__.constructor.call(this)}return a.Extend(b,a.Observable),b.prototype.current=function(a){throw new Error("The `current` method must be defined in child classes.")},b.prototype.query=function(a,b){throw new Error("The `query` method must be defined in child classes.")},b.prototype.bind=function(a,b){},b.prototype.destroy=function(){},b.prototype.generateResultId=function(b,c){var d=b.id+"-result-";return d+=a.generateChars(4),d+=null!=c.id?"-"+c.id.toString():"-"+a.generateChars(4)},b}),b.define("select2/data/select",["./base","../utils","jquery"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,a),d.prototype.current=function(a){var b=[],d=this;this.$element.find(":selected").each(function(){var a=c(this),e=d.item(a);b.push(e)}),a(b)},d.prototype.select=function(a){var b=this;if(a.selected=!0,c(a.element).is("option"))return a.element.selected=!0,void this.$element.trigger("change");
+if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push.apply(a,d);for(var f=0;f=0){var k=f.filter(d(j)),l=this.item(k),m=c.extend(!0,{},j,l),n=this.option(m);k.replaceWith(n)}else{var o=this.option(j);if(j.children){var p=this.convertToOptions(j.children);b.appendMany(o,p)}h.push(o)}}return h},d}),b.define("select2/data/ajax",["./array","../utils","jquery"],function(a,b,c){function d(a,b){this.ajaxOptions=this._applyDefaults(b.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),d.__super__.constructor.call(this,a,b)}return b.Extend(d,a),d.prototype._applyDefaults=function(a){var b={data:function(a){return c.extend({},a,{q:a.term})},transport:function(a,b,d){var e=c.ajax(a);return e.then(b),e.fail(d),e}};return c.extend({},b,a,!0)},d.prototype.processResults=function(a){return a},d.prototype.query=function(a,b){function d(){var d=f.transport(f,function(d){var f=e.processResults(d,a);e.options.get("debug")&&window.console&&console.error&&(f&&f.results&&c.isArray(f.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),b(f)},function(){d.status&&"0"===d.status||e.trigger("results:message",{message:"errorLoading"})});e._request=d}var e=this;null!=this._request&&(c.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var f=c.extend({type:"GET"},this.ajaxOptions);"function"==typeof f.url&&(f.url=f.url.call(this.$element,a)),"function"==typeof f.data&&(f.data=f.data.call(this.$element,a)),this.ajaxOptions.delay&&null!=a.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(d,this.ajaxOptions.delay)):d()},d}),b.define("select2/data/tags",["jquery"],function(a){function b(b,c,d){var e=d.get("tags"),f=d.get("createTag");void 0!==f&&(this.createTag=f);var g=d.get("insertTag");if(void 0!==g&&(this.insertTag=g),b.call(this,c,d),a.isArray(e))for(var h=0;h0&&b.term.length>this.maximumInputLength?void this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),b.define("select2/data/maximumSelectionLength",[],function(){function a(a,b,c){this.maximumSelectionLength=c.get("maximumSelectionLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){var d=this;this.current(function(e){var f=null!=e?e.length:0;return d.maximumSelectionLength>0&&f>=d.maximumSelectionLength?void d.trigger("results:message",{message:"maximumSelected",args:{maximum:d.maximumSelectionLength}}):void a.call(d,b,c)})},a}),b.define("select2/dropdown",["jquery","./utils"],function(a,b){function c(a,b){this.$element=a,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a(' ');return b.attr("dir",this.options.get("dir")),this.$dropdown=b,b},c.prototype.bind=function(){},c.prototype.position=function(a,b){},c.prototype.destroy=function(){this.$dropdown.remove()},c}),b.define("select2/dropdown/search",["jquery","../utils"],function(a,b){function c(){}return c.prototype.render=function(b){var c=b.call(this),d=a(' ');return this.$searchContainer=d,this.$search=d.find("input"),c.prepend(d),c},c.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),this.$search.on("keydown",function(a){e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented()}),this.$search.on("input",function(b){a(this).off("keyup")}),this.$search.on("keyup input",function(a){e.handleSearch(a)}),c.on("open",function(){e.$search.attr("tabindex",0),e.$search.focus(),window.setTimeout(function(){e.$search.focus()},0)}),c.on("close",function(){e.$search.attr("tabindex",-1),e.$search.val("")}),c.on("focus",function(){c.isOpen()&&e.$search.focus()}),c.on("results:all",function(a){if(null==a.query.term||""===a.query.term){var b=e.showSearch(a);b?e.$searchContainer.removeClass("select2-search--hide"):e.$searchContainer.addClass("select2-search--hide")}})},c.prototype.handleSearch=function(a){if(!this._keyUpPrevented){var b=this.$search.val();this.trigger("query",{term:b})}this._keyUpPrevented=!1},c.prototype.showSearch=function(a,b){return!0},c}),b.define("select2/dropdown/hidePlaceholder",[],function(){function a(a,b,c,d){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c,d)}return a.prototype.append=function(a,b){b.results=this.removePlaceholder(b.results),a.call(this,b)},a.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},a.prototype.removePlaceholder=function(a,b){for(var c=b.slice(0),d=b.length-1;d>=0;d--){var e=b[d];this.placeholder.id===e.id&&c.splice(d,1)}return c},a}),b.define("select2/dropdown/infiniteScroll",["jquery"],function(a){function b(a,b,c,d){this.lastParams={},a.call(this,b,c,d),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return b.prototype.append=function(a,b){this.$loadingMore.remove(),this.loading=!1,a.call(this,b),this.showLoadingMore(b)&&this.$results.append(this.$loadingMore)},b.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),c.on("query",function(a){e.lastParams=a,e.loading=!0}),c.on("query:append",function(a){e.lastParams=a,e.loading=!0}),this.$results.on("scroll",function(){var b=a.contains(document.documentElement,e.$loadingMore[0]);if(!e.loading&&b){var c=e.$results.offset().top+e.$results.outerHeight(!1),d=e.$loadingMore.offset().top+e.$loadingMore.outerHeight(!1);c+50>=d&&e.loadMore()}})},b.prototype.loadMore=function(){this.loading=!0;var b=a.extend({},{page:1},this.lastParams);b.page++,this.trigger("query:append",b)},b.prototype.showLoadingMore=function(a,b){return b.pagination&&b.pagination.more},b.prototype.createLoadingMore=function(){var b=a(' '),c=this.options.get("translations").get("loadingMore");return b.html(c(this.lastParams)),b},b}),b.define("select2/dropdown/attachBody",["jquery","../utils"],function(a,b){function c(b,c,d){this.$dropdownParent=d.get("dropdownParent")||a(document.body),b.call(this,c,d)}return c.prototype.bind=function(a,b,c){var d=this,e=!1;a.call(this,b,c),b.on("open",function(){d._showDropdown(),d._attachPositioningHandler(b),e||(e=!0,b.on("results:all",function(){d._positionDropdown(),d._resizeDropdown()}),b.on("results:append",function(){d._positionDropdown(),d._resizeDropdown()}))}),b.on("close",function(){d._hideDropdown(),d._detachPositioningHandler(b)}),this.$dropdownContainer.on("mousedown",function(a){a.stopPropagation()})},c.prototype.destroy=function(a){a.call(this),this.$dropdownContainer.remove()},c.prototype.position=function(a,b,c){b.attr("class",c.attr("class")),b.removeClass("select2"),b.addClass("select2-container--open"),b.css({position:"absolute",top:-999999}),this.$container=c},c.prototype.render=function(b){var c=a(" "),d=b.call(this);return c.append(d),this.$dropdownContainer=c,c},c.prototype._hideDropdown=function(a){this.$dropdownContainer.detach()},c.prototype._attachPositioningHandler=function(c,d){var e=this,f="scroll.select2."+d.id,g="resize.select2."+d.id,h="orientationchange.select2."+d.id,i=this.$container.parents().filter(b.hasScroll);i.each(function(){a(this).data("select2-scroll-position",{x:a(this).scrollLeft(),y:a(this).scrollTop()})}),i.on(f,function(b){var c=a(this).data("select2-scroll-position");a(this).scrollTop(c.y)}),a(window).on(f+" "+g+" "+h,function(a){e._positionDropdown(),e._resizeDropdown()})},c.prototype._detachPositioningHandler=function(c,d){var e="scroll.select2."+d.id,f="resize.select2."+d.id,g="orientationchange.select2."+d.id,h=this.$container.parents().filter(b.hasScroll);h.off(e),a(window).off(e+" "+f+" "+g)},c.prototype._positionDropdown=function(){var b=a(window),c=this.$dropdown.hasClass("select2-dropdown--above"),d=this.$dropdown.hasClass("select2-dropdown--below"),e=null,f=this.$container.offset();f.bottom=f.top+this.$container.outerHeight(!1);var g={height:this.$container.outerHeight(!1)};g.top=f.top,g.bottom=f.top+g.height;var h={height:this.$dropdown.outerHeight(!1)},i={top:b.scrollTop(),bottom:b.scrollTop()+b.height()},j=i.topf.bottom+h.height,l={left:f.left,top:g.bottom},m=this.$dropdownParent;"static"===m.css("position")&&(m=m.offsetParent());var n=m.offset();l.top-=n.top,l.left-=n.left,c||d||(e="below"),k||!j||c?!j&&k&&c&&(e="below"):e="above",("above"==e||c&&"below"!==e)&&(l.top=g.top-n.top-h.height),null!=e&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+e),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+e)),this.$dropdownContainer.css(l)},c.prototype._resizeDropdown=function(){var a={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(a.minWidth=a.width,a.position="relative",a.width="auto"),this.$dropdown.css(a)},c.prototype._showDropdown=function(a){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},c}),b.define("select2/dropdown/minimumResultsForSearch",[],function(){function a(b){for(var c=0,d=0;d0&&(l.dataAdapter=j.Decorate(l.dataAdapter,r)),l.maximumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,s)),l.maximumSelectionLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,t)),l.tags&&(l.dataAdapter=j.Decorate(l.dataAdapter,p)),(null!=l.tokenSeparators||null!=l.tokenizer)&&(l.dataAdapter=j.Decorate(l.dataAdapter,q)),null!=l.query){var C=b(l.amdBase+"compat/query");l.dataAdapter=j.Decorate(l.dataAdapter,C)}if(null!=l.initSelection){var D=b(l.amdBase+"compat/initSelection");l.dataAdapter=j.Decorate(l.dataAdapter,D)}}if(null==l.resultsAdapter&&(l.resultsAdapter=c,null!=l.ajax&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,x)),null!=l.placeholder&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,w)),l.selectOnClose&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,A))),null==l.dropdownAdapter){if(l.multiple)l.dropdownAdapter=u;else{var E=j.Decorate(u,v);l.dropdownAdapter=E}if(0!==l.minimumResultsForSearch&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,z)),l.closeOnSelect&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,B)),null!=l.dropdownCssClass||null!=l.dropdownCss||null!=l.adaptDropdownCssClass){var F=b(l.amdBase+"compat/dropdownCss");l.dropdownAdapter=j.Decorate(l.dropdownAdapter,F)}l.dropdownAdapter=j.Decorate(l.dropdownAdapter,y)}if(null==l.selectionAdapter){if(l.multiple?l.selectionAdapter=e:l.selectionAdapter=d,null!=l.placeholder&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,f)),l.allowClear&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,g)),l.multiple&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,h)),null!=l.containerCssClass||null!=l.containerCss||null!=l.adaptContainerCssClass){var G=b(l.amdBase+"compat/containerCss");l.selectionAdapter=j.Decorate(l.selectionAdapter,G)}l.selectionAdapter=j.Decorate(l.selectionAdapter,i)}if("string"==typeof l.language)if(l.language.indexOf("-")>0){var H=l.language.split("-"),I=H[0];l.language=[l.language,I]}else l.language=[l.language];if(a.isArray(l.language)){var J=new k;l.language.push("en");for(var K=l.language,L=0;L0){for(var f=a.extend(!0,{},e),g=e.children.length-1;g>=0;g--){var h=e.children[g],i=c(d,h);null==i&&f.children.splice(g,1)}return f.children.length>0?f:c(d,f)}var j=b(e.text).toUpperCase(),k=b(d.term).toUpperCase();return j.indexOf(k)>-1?e:null}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:j.escapeMarkup,language:C,matcher:c,minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,sorter:function(a){return a},templateResult:function(a){return a.text},templateSelection:function(a){return a.text},theme:"default",width:"resolve"}},D.prototype.set=function(b,c){var d=a.camelCase(b),e={};e[d]=c;var f=j._convertData(e);a.extend(this.defaults,f)};var E=new D;return E}),b.define("select2/options",["require","jquery","./defaults","./utils"],function(a,b,c,d){function e(b,e){if(this.options=b,null!=e&&this.fromElement(e),this.options=c.apply(this.options),e&&e.is("input")){var f=a(this.get("amdBase")+"compat/inputData");this.options.dataAdapter=d.Decorate(this.options.dataAdapter,f)}}return e.prototype.fromElement=function(a){var c=["select2"];null==this.options.multiple&&(this.options.multiple=a.prop("multiple")),null==this.options.disabled&&(this.options.disabled=a.prop("disabled")),null==this.options.language&&(a.prop("lang")?this.options.language=a.prop("lang").toLowerCase():a.closest("[lang]").prop("lang")&&(this.options.language=a.closest("[lang]").prop("lang"))),null==this.options.dir&&(a.prop("dir")?this.options.dir=a.prop("dir"):a.closest("[dir]").prop("dir")?this.options.dir=a.closest("[dir]").prop("dir"):this.options.dir="ltr"),a.prop("disabled",this.options.disabled),a.prop("multiple",this.options.multiple),a.data("select2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),a.data("data",a.data("select2Tags")),a.data("tags",!0)),a.data("ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),a.attr("ajax--url",a.data("ajaxUrl")),a.data("ajax--url",a.data("ajaxUrl")));var e={};e=b.fn.jquery&&"1."==b.fn.jquery.substr(0,2)&&a[0].dataset?b.extend(!0,{},a[0].dataset,a.data()):a.data();var f=b.extend(!0,{},e);f=d._convertData(f);for(var g in f)b.inArray(g,c)>-1||(b.isPlainObject(this.options[g])?b.extend(this.options[g],f[g]):this.options[g]=f[g]);return this},e.prototype.get=function(a){return this.options[a]},e.prototype.set=function(a,b){this.options[a]=b},e}),b.define("select2/core",["jquery","./options","./utils","./keys"],function(a,b,c,d){var e=function(a,c){null!=a.data("select2")&&a.data("select2").destroy(),this.$element=a,this.id=this._generateId(a),c=c||{},this.options=new b(c,a),e.__super__.constructor.call(this);var d=a.attr("tabindex")||0;a.data("old-tabindex",d),a.attr("tabindex","-1");var f=this.options.get("dataAdapter");this.dataAdapter=new f(a,this.options);var g=this.render();this._placeContainer(g);var h=this.options.get("selectionAdapter");this.selection=new h(a,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,g);var i=this.options.get("dropdownAdapter");this.dropdown=new i(a,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,g);var j=this.options.get("resultsAdapter");this.results=new j(a,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var k=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(a){k.trigger("selection:update",{data:a})}),a.addClass("select2-hidden-accessible"),a.attr("aria-hidden","true"),this._syncAttributes(),a.data("select2",this)};return c.Extend(e,c.Observable),e.prototype._generateId=function(a){var b="";return b=null!=a.attr("id")?a.attr("id"):null!=a.attr("name")?a.attr("name")+"-"+c.generateChars(2):c.generateChars(4),b=b.replace(/(:|\.|\[|\]|,)/g,""),b="select2-"+b},e.prototype._placeContainer=function(a){a.insertAfter(this.$element);var b=this._resolveWidth(this.$element,this.options.get("width"));null!=b&&a.css("width",b)},e.prototype._resolveWidth=function(a,b){var c=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==b){var d=this._resolveWidth(a,"style");return null!=d?d:this._resolveWidth(a,"element")}if("element"==b){var e=a.outerWidth(!1);return 0>=e?"auto":e+"px"}if("style"==b){var f=a.attr("style");if("string"!=typeof f)return null;for(var g=f.split(";"),h=0,i=g.length;i>h;h+=1){var j=g[h].replace(/\s/g,""),k=j.match(c);if(null!==k&&k.length>=1)return k[1]}return null}return b},e.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},e.prototype._registerDomEvents=function(){var b=this;this.$element.on("change.select2",function(){b.dataAdapter.current(function(a){b.trigger("selection:update",{data:a})})}),this.$element.on("focus.select2",function(a){b.trigger("focus",a)}),this._syncA=c.bind(this._syncAttributes,this),this._syncS=c.bind(this._syncSubtree,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._syncA);var d=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=d?(this._observer=new d(function(c){a.each(c,b._syncA),a.each(c,b._syncS)}),this._observer.observe(this.$element[0],{attributes:!0,childList:!0,subtree:!1})):this.$element[0].addEventListener&&(this.$element[0].addEventListener("DOMAttrModified",b._syncA,!1),this.$element[0].addEventListener("DOMNodeInserted",b._syncS,!1),this.$element[0].addEventListener("DOMNodeRemoved",b._syncS,!1))},e.prototype._registerDataEvents=function(){var a=this;this.dataAdapter.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerSelectionEvents=function(){var b=this,c=["toggle","focus"];this.selection.on("toggle",function(){b.toggleDropdown()}),this.selection.on("focus",function(a){b.focus(a)}),this.selection.on("*",function(d,e){-1===a.inArray(d,c)&&b.trigger(d,e)})},e.prototype._registerDropdownEvents=function(){var a=this;this.dropdown.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerResultsEvents=function(){var a=this;this.results.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerEvents=function(){var a=this;this.on("open",function(){a.$container.addClass("select2-container--open")}),this.on("close",function(){a.$container.removeClass("select2-container--open")}),this.on("enable",function(){a.$container.removeClass("select2-container--disabled")}),this.on("disable",function(){a.$container.addClass("select2-container--disabled")}),this.on("blur",function(){a.$container.removeClass("select2-container--focus")}),this.on("query",function(b){a.isOpen()||a.trigger("open",{}),this.dataAdapter.query(b,function(c){a.trigger("results:all",{data:c,query:b})})}),this.on("query:append",function(b){this.dataAdapter.query(b,function(c){a.trigger("results:append",{data:c,query:b})})}),this.on("keypress",function(b){var c=b.which;a.isOpen()?c===d.ESC||c===d.TAB||c===d.UP&&b.altKey?(a.close(),b.preventDefault()):c===d.ENTER?(a.trigger("results:select",{}),b.preventDefault()):c===d.SPACE&&b.ctrlKey?(a.trigger("results:toggle",{}),b.preventDefault()):c===d.UP?(a.trigger("results:previous",{}),b.preventDefault()):c===d.DOWN&&(a.trigger("results:next",{}),b.preventDefault()):(c===d.ENTER||c===d.SPACE||c===d.DOWN&&b.altKey)&&(a.open(),b.preventDefault())})},e.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.options.get("disabled")?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},e.prototype._syncSubtree=function(a,b){var c=!1,d=this;if(!a||!a.target||"OPTION"===a.target.nodeName||"OPTGROUP"===a.target.nodeName){if(b)if(b.addedNodes&&b.addedNodes.length>0)for(var e=0;e0&&(c=!0);else c=!0;c&&this.dataAdapter.current(function(a){d.trigger("selection:update",{data:a})})}},e.prototype.trigger=function(a,b){var c=e.__super__.trigger,d={open:"opening",close:"closing",select:"selecting",unselect:"unselecting"};if(void 0===b&&(b={}),a in d){var f=d[a],g={prevented:!1,name:a,args:b};if(c.call(this,f,g),g.prevented)return void(b.prevented=!0)}c.call(this,a,b)},e.prototype.toggleDropdown=function(){this.options.get("disabled")||(this.isOpen()?this.close():this.open())},e.prototype.open=function(){this.isOpen()||this.trigger("query",{})},e.prototype.close=function(){this.isOpen()&&this.trigger("close",{})},e.prototype.isOpen=function(){return this.$container.hasClass("select2-container--open")},e.prototype.hasFocus=function(){return this.$container.hasClass("select2-container--focus")},e.prototype.focus=function(a){this.hasFocus()||(this.$container.addClass("select2-container--focus"),this.trigger("focus",{}))},e.prototype.enable=function(a){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'),(null==a||0===a.length)&&(a=[!0]);var b=!a[0];this.$element.prop("disabled",b)},e.prototype.data=function(){this.options.get("debug")&&arguments.length>0&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.');var a=[];return this.dataAdapter.current(function(b){a=b}),a},e.prototype.val=function(b){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==b||0===b.length)return this.$element.val();var c=b[0];a.isArray(c)&&(c=a.map(c,function(a){return a.toString()})),this.$element.val(c).trigger("change")},e.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._syncA),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&(this.$element[0].removeEventListener("DOMAttrModified",this._syncA,!1),this.$element[0].removeEventListener("DOMNodeInserted",this._syncS,!1),this.$element[0].removeEventListener("DOMNodeRemoved",this._syncS,!1)),this._syncA=null,this._syncS=null,this.$element.off(".select2"),this.$element.attr("tabindex",this.$element.data("old-tabindex")),this.$element.removeClass("select2-hidden-accessible"),this.$element.attr("aria-hidden","false"),this.$element.removeData("select2"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null;
+},e.prototype.render=function(){var b=a(' ');return b.attr("dir",this.options.get("dir")),this.$container=b,this.$container.addClass("select2-container--"+this.options.get("theme")),b.data("element",this.$element),b},e}),b.define("jquery-mousewheel",["jquery"],function(a){return a}),b.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults"],function(a,b,c,d){if(null==a.fn.select2){var e=["open","close","destroy"];a.fn.select2=function(b){if(b=b||{},"object"==typeof b)return this.each(function(){var d=a.extend(!0,{},b);new c(a(this),d)}),this;if("string"==typeof b){var d,f=Array.prototype.slice.call(arguments,1);return this.each(function(){var c=a(this).data("select2");null==c&&window.console&&console.error&&console.error("The select2('"+b+"') method was called on an element that is not using Select2."),d=c[b].apply(c,f)}),a.inArray(b,e)>-1?this:d}throw new Error("Invalid arguments for Select2: "+b)}}return null==a.fn.select2.defaults&&(a.fn.select2.defaults=d),c}),{define:b.define,require:b.require}}(),c=b.require("jquery.select2");return a.fn.select2.amd=b,c});
\ No newline at end of file
diff --git a/app/assets/stylesheets/select2.css b/app/assets/stylesheets/select2.css
index 2fc34c9..d2278f9 100644
--- a/app/assets/stylesheets/select2.css
+++ b/app/assets/stylesheets/select2.css
@@ -1,641 +1 @@
-/*
-Version: 3.4.2 Timestamp Mon Aug 12 15:04:12 PDT 2013
-*/
-.select2-container {
- margin: 0;
- position: relative;
- display: inline-block;
- /* inline-block for ie7 */
- zoom: 1;
- *display: inline;
- vertical-align: middle;
-}
-
-.select2-container,
-.select2-drop,
-.select2-search,
-.select2-search input {
- /*
- Force border-box so that % widths fit the parent
- container without overlap because of margin/padding.
-
- More Info : http://www.quirksmode.org/css/box.html
- */
- -webkit-box-sizing: border-box; /* webkit */
- -moz-box-sizing: border-box; /* firefox */
- box-sizing: border-box; /* css3 */
-}
-
-.select2-container .select2-choice {
- display: block;
- height: 26px;
- padding: 0 0 0 8px;
- overflow: hidden;
- position: relative;
-
- border: 1px solid #aaa;
- white-space: nowrap;
- line-height: 26px;
- color: #444;
- text-decoration: none;
-
- border-radius: 4px;
-
- background-clip: padding-box;
-
- -webkit-touch-callout: none;
- -webkit-user-select: none;
- -khtml-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
-
- background-color: #fff;
- background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.5, #fff));
- background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 50%);
- background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 50%);
- background-image: -o-linear-gradient(bottom, #eee 0%, #fff 50%);
- background-image: -ms-linear-gradient(top, #fff 0%, #eee 50%);
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#eeeeee', GradientType = 0);
- background-image: linear-gradient(top, #fff 0%, #eee 50%);
-}
-
-.select2-container .select2-chosen {
- color: #444444;
-}
-
-.select2-container.select2-drop-above .select2-choice {
- border-bottom-color: #aaa;
-
- border-radius: 0 0 4px 4px;
-
- background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.9, #fff));
- background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 90%);
- background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 90%);
- background-image: -o-linear-gradient(bottom, #eee 0%, #fff 90%);
- background-image: -ms-linear-gradient(top, #eee 0%, #fff 90%);
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0);
- background-image: linear-gradient(top, #eee 0%, #fff 90%);
-}
-
-.select2-container.select2-allowclear .select2-choice .select2-chosen {
- margin-right: 42px;
-}
-
-.select2-container .select2-choice > .select2-chosen {
- margin-right: 26px;
- display: block;
- overflow: hidden;
-
- white-space: nowrap;
-
- text-overflow: ellipsis;
-}
-
-.select2-container .select2-choice abbr {
- display: none;
- width: 12px;
- height: 12px;
- position: absolute;
- right: 24px;
- top: 8px;
-
- font-size: 1px;
- text-decoration: none;
-
- border: 0;
- background: url('/assets/select2.png') right top no-repeat;
- cursor: pointer;
- outline: 0;
-}
-
-.select2-container.select2-allowclear .select2-choice abbr {
- display: inline-block;
-}
-
-.select2-container .select2-choice abbr:hover {
- background-position: right -11px;
- cursor: pointer;
-}
-
-.select2-drop-mask {
- border: 0;
- margin: 0;
- padding: 0;
- position: fixed;
- left: 0;
- top: 0;
- min-height: 100%;
- min-width: 100%;
- height: auto;
- width: auto;
- opacity: 0;
- z-index: 9998;
- /* styles required for IE to work */
- background-color: #fff;
- opacity: 0;
- filter: alpha(opacity=0);
-}
-
-.select2-drop {
- width: 100%;
- margin-top: -1px;
- position: absolute;
- z-index: 9999;
- top: 100%;
-
- background: #fff;
- color: #000;
- border: 1px solid #aaa;
- border-top: 0;
-
- border-radius: 0 0 4px 4px;
-
- -webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
- box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
-}
-
-.select2-drop-auto-width {
- border-top: 1px solid #aaa;
- width: auto;
-}
-
-.select2-drop-auto-width .select2-search {
- padding-top: 4px;
-}
-
-.select2-drop.select2-drop-above {
- margin-top: 1px;
- border-top: 1px solid #aaa;
- border-bottom: 0;
-
- border-radius: 4px 4px 0 0;
-
- -webkit-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
- box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
-}
-
-.select2-drop-active {
- border: 1px solid #5897fb;
- border-top: none;
-}
-
-.select2-drop.select2-drop-above.select2-drop-active {
- border-top: 1px solid #5897fb;
-}
-
-.select2-container .select2-choice .select2-arrow {
- display: inline-block;
- width: 18px;
- height: 100%;
- position: absolute;
- right: 0;
- top: 0;
-
- border-left: 1px solid #aaa;
- border-radius: 0 4px 4px 0;
-
- background-clip: padding-box;
-
- background: #ccc;
- background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee));
- background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%);
- background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%);
- background-image: -o-linear-gradient(bottom, #ccc 0%, #eee 60%);
- background-image: -ms-linear-gradient(top, #ccc 0%, #eee 60%);
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#cccccc', GradientType = 0);
- background-image: linear-gradient(top, #ccc 0%, #eee 60%);
-}
-
-.select2-container .select2-choice .select2-arrow b {
- display: block;
- width: 100%;
- height: 100%;
- background: url('/assets/select2.png') no-repeat 0 1px;
-}
-
-.select2-search {
- display: inline-block;
- width: 100%;
- min-height: 26px;
- margin: 0;
- padding-left: 4px;
- padding-right: 4px;
-
- position: relative;
- z-index: 10000;
-
- white-space: nowrap;
-}
-
-.select2-search input {
- width: 100%;
- height: auto !important;
- min-height: 26px;
- padding: 4px 20px 4px 5px;
- margin: 0;
-
- outline: 0;
- font-family: sans-serif;
- font-size: 1em;
-
- border: 1px solid #aaa;
- border-radius: 0;
-
- -webkit-box-shadow: none;
- box-shadow: none;
-
- background: #fff url('/assets/select2.png') no-repeat 100% -22px;
- background: url('/assets/select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
- background: url('/assets/select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
- background: url('/assets/select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
- background: url('/assets/select2.png') no-repeat 100% -22px, -o-linear-gradient(bottom, #fff 85%, #eee 99%);
- background: url('/assets/select2.png') no-repeat 100% -22px, -ms-linear-gradient(top, #fff 85%, #eee 99%);
- background: url('/assets/select2.png') no-repeat 100% -22px, linear-gradient(top, #fff 85%, #eee 99%);
-}
-
-.select2-drop.select2-drop-above .select2-search input {
- margin-top: 4px;
-}
-
-.select2-search input.select2-active {
- background: #fff url('/assets/select2-spinner.gif') no-repeat 100%;
- background: url('/assets/select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
- background: url('/assets/select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
- background: url('/assets/select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
- background: url('/assets/select2-spinner.gif') no-repeat 100%, -o-linear-gradient(bottom, #fff 85%, #eee 99%);
- background: url('/assets/select2-spinner.gif') no-repeat 100%, -ms-linear-gradient(top, #fff 85%, #eee 99%);
- background: url('/assets/select2-spinner.gif') no-repeat 100%, linear-gradient(top, #fff 85%, #eee 99%);
-}
-
-.select2-container-active .select2-choice,
-.select2-container-active .select2-choices {
- border: 1px solid #5897fb;
- outline: none;
-
- -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
- box-shadow: 0 0 5px rgba(0, 0, 0, .3);
-}
-
-.select2-dropdown-open .select2-choice {
- border-bottom-color: transparent;
- -webkit-box-shadow: 0 1px 0 #fff inset;
- box-shadow: 0 1px 0 #fff inset;
-
- border-bottom-left-radius: 0;
- border-bottom-right-radius: 0;
-
- background-color: #eee;
- background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #fff), color-stop(0.5, #eee));
- background-image: -webkit-linear-gradient(center bottom, #fff 0%, #eee 50%);
- background-image: -moz-linear-gradient(center bottom, #fff 0%, #eee 50%);
- background-image: -o-linear-gradient(bottom, #fff 0%, #eee 50%);
- background-image: -ms-linear-gradient(top, #fff 0%, #eee 50%);
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
- background-image: linear-gradient(top, #fff 0%, #eee 50%);
-}
-
-.select2-dropdown-open.select2-drop-above .select2-choice,
-.select2-dropdown-open.select2-drop-above .select2-choices {
- border: 1px solid #5897fb;
- border-top-color: transparent;
-
- background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(0.5, #eee));
- background-image: -webkit-linear-gradient(center top, #fff 0%, #eee 50%);
- background-image: -moz-linear-gradient(center top, #fff 0%, #eee 50%);
- background-image: -o-linear-gradient(top, #fff 0%, #eee 50%);
- background-image: -ms-linear-gradient(bottom, #fff 0%, #eee 50%);
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
- background-image: linear-gradient(bottom, #fff 0%, #eee 50%);
-}
-
-.select2-dropdown-open .select2-choice .select2-arrow {
- background: transparent;
- border-left: none;
- filter: none;
-}
-.select2-dropdown-open .select2-choice .select2-arrow b {
- background-position: -18px 1px;
-}
-
-/* results */
-.select2-results {
- max-height: 200px;
- padding: 0 0 0 4px;
- margin: 4px 4px 4px 0;
- position: relative;
- overflow-x: hidden;
- overflow-y: auto;
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
-}
-
-.select2-results ul.select2-result-sub {
- margin: 0;
- padding-left: 0;
-}
-
-.select2-results ul.select2-result-sub > li .select2-result-label { padding-left: 20px }
-.select2-results ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 40px }
-.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 60px }
-.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 80px }
-.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 100px }
-.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 110px }
-.select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 120px }
-
-.select2-results li {
- list-style: none;
- display: list-item;
- background-image: none;
-}
-
-.select2-results li.select2-result-with-children > .select2-result-label {
- font-weight: bold;
-}
-
-.select2-results .select2-result-label {
- padding: 3px 7px 4px;
- margin: 0;
- cursor: pointer;
-
- min-height: 1em;
-
- -webkit-touch-callout: none;
- -webkit-user-select: none;
- -khtml-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
-}
-
-.select2-results .select2-highlighted {
- background: #3875d7;
- color: #fff;
-}
-
-.select2-results li em {
- background: #feffde;
- font-style: normal;
-}
-
-.select2-results .select2-highlighted em {
- background: transparent;
-}
-
-.select2-results .select2-highlighted ul {
- background: #fff;
- color: #000;
-}
-
-
-.select2-results .select2-no-results,
-.select2-results .select2-searching,
-.select2-results .select2-selection-limit {
- background: #f4f4f4;
- display: list-item;
-}
-
-/*
-disabled look for disabled choices in the results dropdown
-*/
-.select2-results .select2-disabled.select2-highlighted {
- color: #666;
- background: #f4f4f4;
- display: list-item;
- cursor: default;
-}
-.select2-results .select2-disabled {
- background: #f4f4f4;
- display: list-item;
- cursor: default;
-}
-
-.select2-results .select2-selected {
- display: none;
-}
-
-.select2-more-results.select2-active {
- background: #f4f4f4 url('/assets/select2-spinner.gif') no-repeat 100%;
-}
-
-.select2-more-results {
- background: #f4f4f4;
- display: list-item;
-}
-
-/* disabled styles */
-
-.select2-container.select2-container-disabled .select2-choice {
- background-color: #f4f4f4;
- background-image: none;
- border: 1px solid #ddd;
- cursor: default;
-}
-
-.select2-container.select2-container-disabled .select2-choice .select2-arrow {
- background-color: #f4f4f4;
- background-image: none;
- border-left: 0;
-}
-
-.select2-container.select2-container-disabled .select2-choice abbr {
- display: none;
-}
-
-
-/* multiselect */
-
-.select2-container-multi .select2-choices {
- height: auto !important;
- height: 1%;
- margin: 0;
- padding: 0;
- position: relative;
-
- border: 1px solid #aaa;
- cursor: text;
- overflow: hidden;
-
- background-color: #fff;
- background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eee), color-stop(15%, #fff));
- background-image: -webkit-linear-gradient(top, #eee 1%, #fff 15%);
- background-image: -moz-linear-gradient(top, #eee 1%, #fff 15%);
- background-image: -o-linear-gradient(top, #eee 1%, #fff 15%);
- background-image: -ms-linear-gradient(top, #eee 1%, #fff 15%);
- background-image: linear-gradient(top, #eee 1%, #fff 15%);
-}
-
-.select2-locked {
- padding: 3px 5px 3px 5px !important;
-}
-
-.select2-container-multi .select2-choices {
- min-height: 26px;
-}
-
-.select2-container-multi.select2-container-active .select2-choices {
- border: 1px solid #5897fb;
- outline: none;
-
- -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
- box-shadow: 0 0 5px rgba(0, 0, 0, .3);
-}
-.select2-container-multi .select2-choices li {
- float: left;
- list-style: none;
-}
-.select2-container-multi .select2-choices .select2-search-field {
- margin: 0;
- padding: 0;
- white-space: nowrap;
-}
-
-.select2-container-multi .select2-choices .select2-search-field input {
- padding: 5px;
- margin: 1px 0;
-
- font-family: sans-serif;
- font-size: 100%;
- color: #666;
- outline: 0;
- border: 0;
- -webkit-box-shadow: none;
- box-shadow: none;
- background: transparent !important;
-}
-
-.select2-container-multi .select2-choices .select2-search-field input.select2-active {
- background: #fff url('/assets/select2-spinner.gif') no-repeat 100% !important;
-}
-
-.select2-default {
- color: #999 !important;
-}
-
-.select2-container-multi .select2-choices .select2-search-choice {
- padding: 3px 5px 3px 18px;
- margin: 3px 0 3px 5px;
- position: relative;
-
- line-height: 13px;
- color: #333;
- cursor: default;
- border: 1px solid #aaaaaa;
-
- border-radius: 3px;
-
- -webkit-box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
- box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
-
- background-clip: padding-box;
-
- -webkit-touch-callout: none;
- -webkit-user-select: none;
- -khtml-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
-
- background-color: #e4e4e4;
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#f4f4f4', GradientType=0);
- background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee));
- background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
- background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
- background-image: -o-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
- background-image: -ms-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
- background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
-}
-.select2-container-multi .select2-choices .select2-search-choice .select2-chosen {
- cursor: default;
-}
-.select2-container-multi .select2-choices .select2-search-choice-focus {
- background: #d4d4d4;
-}
-
-.select2-search-choice-close {
- display: block;
- width: 12px;
- height: 13px;
- position: absolute;
- right: 3px;
- top: 4px;
-
- font-size: 1px;
- outline: none;
- background: url('/assets/select2.png') right top no-repeat;
-}
-
-.select2-container-multi .select2-search-choice-close {
- left: 3px;
-}
-
-.select2-container-multi .select2-choices .select2-search-choice .select2-search-choice-close:hover {
- background-position: right -11px;
-}
-.select2-container-multi .select2-choices .select2-search-choice-focus .select2-search-choice-close {
- background-position: right -11px;
-}
-
-/* disabled styles */
-.select2-container-multi.select2-container-disabled .select2-choices {
- background-color: #f4f4f4;
- background-image: none;
- border: 1px solid #ddd;
- cursor: default;
-}
-
-.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice {
- padding: 3px 5px 3px 5px;
- border: 1px solid #ddd;
- background-image: none;
- background-color: #f4f4f4;
-}
-
-.select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice .select2-search-choice-close { display: none;
- background: none;
-}
-/* end multiselect */
-
-
-.select2-result-selectable .select2-match,
-.select2-result-unselectable .select2-match {
- text-decoration: underline;
-}
-
-.select2-offscreen, .select2-offscreen:focus {
- clip: rect(0 0 0 0) !important;
- width: 1px !important;
- height: 1px !important;
- border: 0 !important;
- margin: 0 !important;
- padding: 0 !important;
- overflow: hidden !important;
- position: absolute !important;
- outline: 0 !important;
- left: 0px !important;
- top: 0px !important;
-}
-
-.select2-display-none {
- display: none;
-}
-
-.select2-measure-scrollbar {
- position: absolute;
- top: -10000px;
- left: -10000px;
- width: 100px;
- height: 100px;
- overflow: scroll;
-}
-/* Retina-ize icons */
-
-@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) {
- .select2-search input, .select2-search-choice-close, .select2-container .select2-choice abbr, .select2-container .select2-choice .select2-arrow b {
- background-image: url('/assets/select2x2.png') !important;
- background-repeat: no-repeat !important;
- background-size: 60px 40px !important;
- }
- .select2-search input {
- background-position: 100% -21px !important;
- }
-}
+.select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:white;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0 !important;clip:rect(0 0 0 0) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important}.select2-container--default .select2-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--default .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--default .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--default.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--default .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--default .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-top:5px;margin-right:10px}.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline{float:right}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--default.select2-container--focus .select2-selection--multiple{border:solid black 1px;outline:0}.select2-container--default.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--default.select2-container--open.select2-container--above .select2-selection--single,.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple{border-top-left-radius:0;border-top-right-radius:0}.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--default .select2-search--dropdown .select2-search__field{border:1px solid #aaa}.select2-container--default .select2-search--inline .select2-search__field{background:transparent;border:none;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--default .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--default .select2-results__option[role=group]{padding:0}.select2-container--default .select2-results__option[aria-disabled=true]{color:#999}.select2-container--default .select2-results__option[aria-selected=true]{background-color:#ddd}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#5897fb;color:white}.select2-container--default .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic .select2-selection--single{background-color:#f7f7f7;border:1px solid #aaa;border-radius:4px;outline:0;background-image:-webkit-linear-gradient(top, #fff 50%, #eee 100%);background-image:-o-linear-gradient(top, #fff 50%, #eee 100%);background-image:linear-gradient(to bottom, #fff 50%, #eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic .select2-selection--single:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--classic .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-right:10px}.select2-container--classic .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--classic .select2-selection--single .select2-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:-webkit-linear-gradient(top, #eee 50%, #ccc 100%);background-image:-o-linear-gradient(top, #eee 50%, #ccc 100%);background-image:linear-gradient(to bottom, #eee 50%, #ccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0)}.select2-container--classic .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto}.select2-container--classic.select2-container--open .select2-selection--single{border:1px solid #5897fb}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow{background:transparent;border:none}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:-webkit-linear-gradient(top, #fff 0%, #eee 50%);background-image:-o-linear-gradient(top, #fff 0%, #eee 50%);background-image:linear-gradient(to bottom, #fff 0%, #eee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:-webkit-linear-gradient(top, #eee 50%, #fff 100%);background-image:-o-linear-gradient(top, #eee 50%, #fff 100%);background-image:linear-gradient(to bottom, #eee 50%, #fff 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0)}.select2-container--classic .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0}.select2-container--classic .select2-selection--multiple:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--multiple .select2-selection__rendered{list-style:none;margin:0;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__clear{display:none}.select2-container--classic .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover{color:#555}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{float:right}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--classic.select2-container--open .select2-selection--multiple{border:1px solid #5897fb}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--classic .select2-search--dropdown .select2-search__field{border:1px solid #aaa;outline:0}.select2-container--classic .select2-search--inline .select2-search__field{outline:0;box-shadow:none}.select2-container--classic .select2-dropdown{background-color:#fff;border:1px solid transparent}.select2-container--classic .select2-dropdown--above{border-bottom:none}.select2-container--classic .select2-dropdown--below{border-top:none}.select2-container--classic .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--classic .select2-results__option[role=group]{padding:0}.select2-container--classic .select2-results__option[aria-disabled=true]{color:grey}.select2-container--classic .select2-results__option--highlighted[aria-selected]{background-color:#3875d7;color:#fff}.select2-container--classic .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic.select2-container--open .select2-dropdown{border-color:#5897fb}
diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb
index 15703bc..e157e76 100644
--- a/app/controllers/answers_controller.rb
+++ b/app/controllers/answers_controller.rb
@@ -1,43 +1,37 @@
class AnswersController < ApplicationController
+ after_action :verify_authorized
# POST /answers
- # POST /answers.json
def create
@answer = Answer.new(params[:answer])
- if (user_signed_in?) && @answer.plan.editable_by(current_user.id) then
- old_answer = @answer.plan.answer(@answer.question_id, false)
- proceed = false
- @answer.text = params["answer-text-#{@answer.question_id}".to_sym]
- if (old_answer.nil? && @answer.text != "") || ((!old_answer.nil?) && (old_answer.text != @answer.text)) then
+ authorize @answer
+ old_answer = @answer.plan.answer(@answer.question_id, false)
+ proceed = false
+ @answer.text = params["answer-text-#{@answer.question_id}".to_sym]
+ if (old_answer.nil? && @answer.text != "") || ((!old_answer.nil?) && (old_answer.text != @answer.text)) then
+ proceed = true
+ end
+
+ if (@answer.question.question_format.title == I18n.t("helpers.checkbox") ||
+ @answer.question.question_format.title == I18n.t("helpers.multi_select_box") ||
+ @answer.question.question_format.title == I18n.t("helpers.radio_buttons") ||
+ @answer.question.question_format.title == I18n.t("helpers.dropdown")) then
+ if (old_answer.nil? && @answer.option_ids.count > 0) || ((!old_answer.nil?) && (old_answer.option_ids - @answer.option_ids).count != 0 && (@answer.option_ids - old_answer.option_ids).count != 0) then
proceed = true
end
-
- if (@answer.question.question_format.title == I18n.t("helpers.checkbox") ||
- @answer.question.question_format.title == I18n.t("helpers.multi_select_box") ||
- @answer.question.question_format.title == I18n.t("helpers.radio_buttons") ||
- @answer.question.question_format.title == I18n.t("helpers.dropdown")) then
- if (old_answer.nil? && @answer.option_ids.count > 0) || ((!old_answer.nil?) && (old_answer.option_ids - @answer.option_ids).count != 0 && (@answer.option_ids - old_answer.option_ids).count != 0) then
- proceed = true
- end
- end
- if proceed
- respond_to do |format|
- if @answer.save
- format.html { redirect_to :back, status: :found, notice: I18n.t('helpers.project.answer_recorded') }
- format.json { render json: @answer, status: :created, location: @answer }
- else
- format.html { redirect_to :back, notice: I18n.t('helpers.project.answer_error') }
- format.json { render json: @answer.errors, status: :unprocessable_entity }
- end
- end
- else
- respond_to do |format|
- format.html { redirect_to :back, notice: I18n.t('helpers.project.answer_no_change') }
- format.json { render json: @answer.errors, status: :unprocessable_entity }
+ end
+ if proceed
+ respond_to do |format|
+ if @answer.save
+ format.html { redirect_to :back, status: :found, notice: I18n.t('helpers.project.answer_recorded') }
+ else
+ format.html { redirect_to :back, notice: I18n.t('helpers.project.answer_error') }
end
end
else
- render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
+ respond_to do |format|
+ format.html { redirect_to :back, notice: I18n.t('helpers.project.answer_no_change') }
+ end
end
- end
+ end
end
\ No newline at end of file
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 5eb574e..005e288 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -3,7 +3,6 @@
include GlobalHelpers
include Pundit
-
helper_method GlobalHelpers.instance_methods
# Override build_footer method in ActiveAdmin::Views::Pages
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index 6d1ce7c..87838cb 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -1,69 +1,39 @@
class CommentsController < ApplicationController
- # GET /comments
- # GET /comments.json
- def index
- @comments = Comment.all
-
- respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @comments }
- end
- end
-
- # GET /comments/1
- # GET /comments/1.json
- def show
- @comment = Comment.find(params[:id])
-
- respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @comment }
- end
- end
-
-
- # GET /comments/1/edit
- def edit
- @comment = Comment.find(params[:id])
- end
+ after_action :verify_authorized
# POST /comments
- # POST /comments.json
def create
- if user_signed_in? then
- @comment = Comment.new(params[:new_comment])
- @comment.text = params["#{params[:new_comment][:question_id]}new_comment_text"]
- @comment.question_id = params[:new_comment][:question_id]
- @comment.user_id = params[:new_comment][:user_id]
- @comment.plan_id = params[:new_comment][:plan_id]
-
- @plan = Plan.find(@comment.plan_id)
- @project = Project.find(@plan.project_id)
-
- respond_to do |format|
- if @comment.save
- session[:question_id_comments] = @comment.question_id
- format.html { redirect_to edit_project_plan_path(@project, @plan), status: :found, notice: I18n.t("helpers.comments.comment_created") }
- format.json { head :no_content }
- end
- end
- end
+ @comment = Comment.new(params[:new_comment])
+ @comment.text = params["#{params[:new_comment][:question_id]}new_comment_text"]
+ @comment.question_id = params[:new_comment][:question_id]
+ @comment.user_id = params[:new_comment][:user_id]
+ @comment.plan_id = params[:new_comment][:plan_id]
+ authorize @comment
+
+ @plan = Plan.find(@comment.plan_id)
+ @project = Project.find(@plan.project_id)
+
+ respond_to do |format|
+ if @comment.save
+ session[:question_id_comments] = @comment.question_id
+ format.html { redirect_to edit_project_plan_path(@project, @plan), status: :found, notice: I18n.t("helpers.comments.comment_created") }
+ end
+ end
end
# PUT /comments/1
- # PUT /comments/1.json
def update
@comment = Comment.find(params[:comment][:id])
+ authorize @comment
@comment.text = params["#{params[:comment][:id]}_comment_text"]
-
+
@plan = Plan.find(@comment.plan_id)
@project = Project.find(@plan.project_id)
-
+
respond_to do |format|
if @comment.update_attributes(params[:comment])
session[:question_id_comments] = @comment.question_id
format.html { redirect_to edit_project_plan_path(@project, @plan), status: :found, notice: I18n.t("helpers.comments.comment_updated") }
- format.json { head :no_content }
end
end
end
@@ -72,9 +42,10 @@
# ARCHIVE /comments/1.json
def archive
@comment = Comment.find(params[:comment][:id])
+ authorize @comment
@comment.archived = true
@comment.archived_by = params[:comment][:archived_by]
-
+
@plan = Plan.find(@comment.plan_id)
@project = Project.find(@plan.project_id)
@@ -82,9 +53,9 @@
if @comment.update_attributes(params[:comment])
session[:question_id_comments] = @comment.question_id
format.html { redirect_to edit_project_plan_path(@project, @plan), status: :found, notice: I18n.t("helpers.comments.comment_removed") }
- end
+ end
end
end
-
-
+
+
end
diff --git a/app/controllers/dmptemplates_controller.rb b/app/controllers/dmptemplates_controller.rb
index 817e961..e7680a5 100644
--- a/app/controllers/dmptemplates_controller.rb
+++ b/app/controllers/dmptemplates_controller.rb
@@ -3,9 +3,9 @@
# [+Copyright:+] Digital Curation Centre and University of California Curation Center
class DmptemplatesController < ApplicationController
+ after_action :verify_authorized
# GET /dmptemplates
- # GET /dmptemplates.json
def admin_index
authorize Dmptemplate
#institutional templates
@@ -18,20 +18,17 @@
end
# GET /dmptemplates/1
- # GET /dmptemplates/1.json
def admin_template
@dmptemplate = Dmptemplate.find(params[:id])
authorize @dmptemplate
respond_to do |format|
format.html # show.html.erb
- format.json { render json: @dmptemplate }
end
end
# PUT /dmptemplates/1
- # PUT /dmptemplates/1.json
def admin_update
@dmptemplate = Dmptemplate.find(params[:id])
authorize @dmptemplate
@@ -39,28 +36,23 @@
respond_to do |format|
if @dmptemplate.update_attributes(params[:dmptemplate])
format.html { redirect_to admin_template_dmptemplate_path(params[:dmptemplate]), notice: I18n.t('org_admin.templates.updated_message') }
- format.json { head :no_content }
else
format.html { render action: "edit" }
- format.json { render json: @dmptemplate.errors, status: :unprocessable_entity }
end
end
end
# GET /dmptemplates/new
- # GET /dmptemplates/new.json
def admin_new
@dmptemplate = Dmptemplate.new
authorize @dmptemplate
respond_to do |format|
format.html # new.html.erb
- format.json { render json: @dmptemplate }
end
end
# POST /dmptemplates
- # POST /dmptemplates.json
def admin_create
@dmptemplate = Dmptemplate.new(params[:dmptemplate])
@dmptemplate.organisation_id = current_user.organisation.id
@@ -69,10 +61,8 @@
respond_to do |format|
if @dmptemplate.save
format.html { redirect_to admin_template_dmptemplate_path(@dmptemplate), notice: I18n.t('org_admin.templates.created_message') }
- format.json { render json: @dmptemplate, status: :created, location: @dmptemplate }
else
format.html { render action: "admin_new" }
- format.json { render json: @dmptemplate.errors, status: :unprocessable_entity }
end
end
end
@@ -80,14 +70,12 @@
# DELETE /dmptemplates/1
- # DELETE /dmptemplates/1.json
def admin_destroy
@dmptemplate = Dmptemplate.find(params[:id])
authorize @dmptemplate
@dmptemplate.destroy
respond_to do |format|
format.html { redirect_to admin_index_dmptemplate_path }
- format.json { head :no_content }
end
end
@@ -178,10 +166,8 @@
respond_to do |format|
if @phase.save
format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') }
- format.json { head :no_content }
else
format.html { render action: "admin_phase" }
- format.json { render json: @phase.errors, status: :unprocessable_entity }
end
end
end
@@ -195,10 +181,8 @@
respond_to do |format|
if @phase.update_attributes(params[:phase])
format.html { redirect_to admin_phase_dmptemplate_path(@phase), notice: I18n.t('org_admin.templates.updated_message') }
- format.json { head :no_content }
else
format.html { render action: "admin_phase" }
- format.json { render json: @phase.errors, status: :unprocessable_entity }
end
end
end
@@ -211,7 +195,6 @@
@phase.destroy
respond_to do |format|
format.html { redirect_to admin_template_dmptemplate_path(@dmptemplate), notice: I18n.t('org_admin.templates.destroyed_message') }
- format.json { head :no_content }
end
end
@@ -238,10 +221,8 @@
respond_to do |format|
if @version.update_attributes(params[:version])
format.html { redirect_to admin_phase_dmptemplate_path(@phase, :version_id => @version.id, :edit => 'false'), notice: I18n.t('org_admin.templates.updated_message') }
- format.json { head :no_content }
else
format.html { render action: "admin_phase" }
- format.json { render json: @version.errors, status: :unprocessable_entity }
end
end
end
@@ -255,10 +236,8 @@
respond_to do |format|
if @version.save
format.html { redirect_to admin_phase_dmptemplate_path(@phase, :version_id => @version.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') }
- format.json { head :no_content }
else
format.html { render action: "admin_phase" }
- format.json { render json: @version.errors, status: :unprocessable_entity }
end
end
end
@@ -271,7 +250,6 @@
@version.destroy
respond_to do |format|
format.html { redirect_to admin_phase_dmptemplate_path(@phase), notice: I18n.t('org_admin.templates.destroyed_message') }
- format.json { head :no_content }
end
end
@@ -286,10 +264,8 @@
respond_to do |format|
if @section.save
format.html { redirect_to admin_phase_dmptemplate_path(:id => @section.version.phase_id, :version_id => @section.version_id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') }
- format.json { head :no_content }
else
format.html { render action: "admin_phase" }
- format.json { render json: @section.errors, status: :unprocessable_entity }
end
end
end
@@ -305,10 +281,8 @@
respond_to do |format|
if @section.update_attributes(params[:section])
format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id , :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') }
- format.json { head :no_content }
else
format.html { render action: "admin_phase" }
- format.json { render json: @section.errors, status: :unprocessable_entity }
end
end
end
@@ -323,7 +297,6 @@
@section.destroy
respond_to do |format|
format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :edit => 'true' ), notice: I18n.t('org_admin.templates.destroyed_message') }
- format.json { head :no_content }
end
end
@@ -339,10 +312,8 @@
respond_to do |format|
if @question.save
format.html { redirect_to admin_phase_dmptemplate_path(:id => @question.section.version.phase_id, :version_id => @question.section.version_id, :section_id => @question.section_id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') }
- format.json { head :no_content }
else
format.html { render action: "admin_phase" }
- format.json { render json: @question.errors, status: :unprocessable_entity }
end
end
end
@@ -359,10 +330,8 @@
respond_to do |format|
if @question.update_attributes(params[:question])
format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') }
- format.json { head :no_content }
else
format.html { render action: "admin_phase" }
- format.json { render json: @question.errors, status: :unprocessable_entity }
end
end
end
@@ -377,7 +346,6 @@
@question.destroy
respond_to do |format|
format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.destroyed_message') }
- format.json { head :no_content }
end
end
@@ -390,10 +358,8 @@
respond_to do |format|
if @suggested_answer.save
format.html { redirect_to admin_phase_dmptemplate_path(:id => @suggested_answer.question.section.version.phase_id, :version_id => @suggested_answer.question.section.version_id, :section_id => @suggested_answer.question.section_id, :question_id => @suggested_answer.question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') }
- format.json { head :no_content }
else
format.html { render action: "admin_phase" }
- format.json { render json: @suggested_answer.errors, status: :unprocessable_entity }
end
end
end
@@ -411,10 +377,8 @@
respond_to do |format|
if @suggested_answer.update_attributes(params[:suggested_answer])
format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') }
- format.json { head :no_content }
else
format.html { render action: "admin_phase" }
- format.json { render json: @suggested_answer.errors, status: :unprocessable_entity }
end
end
end
@@ -430,7 +394,6 @@
@suggested_answer.destroy
respond_to do |format|
format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.destroyed_message') }
- format.json { head :no_content }
end
end
@@ -447,10 +410,8 @@
respond_to do |format|
if @guidance.save
format.html { redirect_to admin_phase_dmptemplate_path(:id => @question.section.version.phase_id, :version_id => @question.section.version_id, :section_id => @question.section_id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.created_message') }
- format.json { head :no_content }
else
format.html { render action: "admin_phase" }
- format.json { render json: @guidance.errors, status: :unprocessable_entity }
end
end
end
@@ -467,10 +428,8 @@
respond_to do |format|
if @question.update_attributes(params[:question])
format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :question_id => @question.id, :edit => 'true'), notice: I18n.t('org_admin.templates.updated_message') }
- format.json { head :no_content }
else
format.html { render action: "admin_phase" }
- format.json { render json: @question.errors, status: :unprocessable_entity }
end
end
end
@@ -485,7 +444,6 @@
@question.destroy
respond_to do |format|
format.html { redirect_to admin_phase_dmptemplate_path(:id => @phase.id, :version_id => @version.id, :section_id => @section.id, :edit => 'true'), notice: I18n.t('org_admin.templates.destroyed_message') }
- format.json { head :no_content }
end
end
diff --git a/app/controllers/guidance_groups_controller.rb b/app/controllers/guidance_groups_controller.rb
index 4c0c900..8b3a6d5 100644
--- a/app/controllers/guidance_groups_controller.rb
+++ b/app/controllers/guidance_groups_controller.rb
@@ -1,14 +1,12 @@
class GuidanceGroupsController < ApplicationController
-
+ after_action :verify_authorized
# GET /guidance_groups/1
- # GET /guidance_groups/1.json
def admin_show
@guidance_group = GuidanceGroup.find(params[:id])
authorize @guidance_group
respond_to do |format|
format.html
- format.json { render json: @guidance_group }
end
end
@@ -19,7 +17,6 @@
authorize @guidance_group
respond_to do |format|
format.html # new.html.erb
- format.json { render json: @guidance }
end
end
@@ -37,10 +34,8 @@
respond_to do |format|
if @guidance_group.save
format.html { redirect_to admin_index_guidance_path, notice: I18n.t('org_admin.guidance_group.created_message') }
- format.json { render json: @guidance_group, status: :created, location: @guidance_group }
else
format.html { render action: "new" }
- format.json { render json: @guidance_group.errors, status: :unprocessable_entity }
end
end
end
@@ -54,7 +49,6 @@
# PUT /guidance_groups/1
- # PUT /guidance_groups/1.json
def admin_update
@guidance_group = GuidanceGroup.find(params[:id])
authorize @guidance_group
@@ -62,10 +56,8 @@
respond_to do |format|
if @guidance_group.update_attributes(params[:guidance_group])
format.html { redirect_to admin_index_guidance_path(params[:guidance_group]), notice: I18n.t('org_admin.guidance_group.updated_message') }
- format.json { head :no_content }
else
format.html { render action: "edit" }
- format.json { render json: @guidance_group.errors, status: :unprocessable_entity }
end
end
end
@@ -81,10 +73,8 @@
respond_to do |format|
if @guidance_group.update_attributes(params[:guidance_group])
format.html { redirect_to admin_index_guidance_path(params[:guidance_group]), notice: I18n.t('org_admin.guidance_group.updated_message') }
- format.json { head :no_content }
else
format.html { render action: "edit" }
- format.json { render json: @guidance_group.errors, status: :unprocessable_entity }
end
end
end
@@ -98,7 +88,6 @@
@guidance_group.destroy
respond_to do |format|
format.html { redirect_to admin_index_guidance_path, notice: I18n.t('org_admin.guidance_group.destroyed_message') }
- format.json { head :no_content }
end
end
diff --git a/app/controllers/guidances_controller.rb b/app/controllers/guidances_controller.rb
index abb2c1e..87b32ca 100644
--- a/app/controllers/guidances_controller.rb
+++ b/app/controllers/guidances_controller.rb
@@ -1,24 +1,22 @@
class GuidancesController < ApplicationController
+ after_action :verify_authorized
+
# GET /guidances
- # GET /guidances.json
def admin_index
authorize Guidance
@guidances = policy_scope(Guidance)
@guidance_groups = GuidanceGroup.where('organisation_id = ?', current_user.organisation_id )
respond_to do |format|
format.html # index.html.erb
- format.json { render json: @guidances }
end
end
# GET /guidances/1
- # GET /guidances/1.json
def admin_show
@guidance = Guidance.find(params[:id])
authorize @guidance
respond_to do |format|
format.html # show.html.erb
- format.json { render json: @guidance }
end
end
@@ -139,7 +137,6 @@
end
# POST /guidances
- # POST /guidances.json
def admin_create
@guidance = Guidance.new(params[:guidance])
authorize @guidance
@@ -155,16 +152,13 @@
respond_to do |format|
if @guidance.save
format.html { redirect_to admin_show_guidance_path(@guidance), notice: I18n.t('org_admin.guidance.created_message') }
- format.json { render json: @guidance, status: :created, location: @guidance }
else
format.html { render action: "new" }
- format.json { render json: @guidance.errors, status: :unprocessable_entity }
end
end
end
# PUT /guidances/1
- # PUT /guidances/1.json
def admin_update
@guidance = Guidance.find(params[:id])
authorize @guidance
@@ -173,25 +167,21 @@
respond_to do |format|
if @guidance.update_attributes(params[:guidance])
format.html { redirect_to admin_show_guidance_path(params[:guidance]), notice: I18n.t('org_admin.guidance.updated_message') }
- format.json { head :no_content }
else
format.html { render action: "edit" }
- format.json { render json: @guidance.errors, status: :unprocessable_entity }
end
end
end
# DELETE /guidances/1
- # DELETE /guidances/1.json
def admin_destroy
@guidance = Guidance.find(params[:id])
authorize @guidance
@guidance.destroy
respond_to do |format|
format.html { redirect_to admin_index_guidance_path }
- format.json { head :no_content }
end
end
-end
+end
\ No newline at end of file
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index 110f579..fe5a071 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -1,16 +1,14 @@
class HomeController < ApplicationController
+
def index
if user_signed_in?
name = current_user.name(false)
- if name.nil? || name == "" then
+ if name.blank?
redirect_to edit_user_registration_path
else
redirect_to projects_url
end
end
end
-
- def about_us
- end
end
diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb
index 16ea960..839d7c4 100644
--- a/app/controllers/organisations_controller.rb
+++ b/app/controllers/organisations_controller.rb
@@ -1,64 +1,26 @@
class OrganisationsController < ApplicationController
- # GET /organisations
- # GET /organisations.json
- def index
- @organisations = Organisation.all
-
- respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @organisations }
- end
- end
-
- # GET /organisations/new
- # GET /organisations/new.json
- def new
- @organisation = Organisation.new
-
- respond_to do |format|
- format.html # new.html.erb
- format.json { render json: @organisation }
- end
- end
-
- # POST /organisations
- # POST /organisations.json
- def create
- @organisation = Organisation.new(params[:organisation])
- @organisation.logo = param[:organisation][:logo]
- respond_to do |format|
- if @organisation.save
- format.html { redirect_to @organisation, notice: I18n.t("admin.org_created_message") }
- format.json { render json: @organisation, status: :created, location: @organisation }
- else
- format.html { render action: "new" }
- format.json { render json: @organisation.errors, status: :unprocessable_entity }
- end
- end
- end
-
+ after_action :verify_authorized
# GET /organisations/1
- # GET /organisations/1.json
def admin_show
@organisation = Organisation.find(params[:id])
authorize @organisation
respond_to do |format|
format.html # show.html.erb
- format.json { render json: @organisation }
end
end
# GET /organisations/1/edit
def admin_edit
- @organisation = authorize Organisation.find(params[:id])
+ @organisation = Organisation.find(params[:id])
+ authorize @organisation
end
# PUT /organisations/1
- # PUT /organisations/1.json
def admin_update
- @organisation = authorize Organisation.find(params[:id])
+ @organisation = Organisation.find(params[:id])
+ authorize @organisation
@organisation.banner_text = params["org_banner_text"]
@organisation.logo = params[:organisation][:logo] if params[:organisation][:logo]
assign_params = params[:organisation].dup
@@ -67,34 +29,24 @@
respond_to do |format|
if @organisation.update_attributes(assign_params)
format.html { redirect_to admin_show_organisation_path(params[:id]), notice: I18n.t("admin.org_updated_message") }
- format.json { head :no_content }
else
format.html { render action: "edit" }
- format.json { render json: @organisation.errors, status: :unprocessable_entity }
end
end
end
- # DELETE /organisations/1
- # DELETE /organisations/1.json
- def destroy
- @organisation = Organisation.find(params[:id])
- @organisation.destroy
-
- respond_to do |format|
- format.html { redirect_to organisations_url }
- format.json { head :no_content }
- end
- end
-
+ #TODO: see if this is used by the ajax... otherwise lock it down
def parent
@organisation = Organisation.find(params[:id])
+ authorize @organisation
parent_org = @organisation.find_by {|o| o.parent_id }
return parent_org
end
+ #TODO: see is this is used by the ajax... otherwise lock it down
def children
@organisation = Organisation.find(params[:id])
+ authorize @organisation
#if user_signed_in? then
children = {}
@organisation.children.each do |child|
@@ -108,8 +60,10 @@
# end
end
+ #TODO: see if this is used by the ajax... otherwise lock it down
def templates
@organisation = Organisation.find(params[:id])
+ authorize @organisation
#if user_signed_in? then
templates = {}
@organisation.dmptemplates.each do |template|
diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb
index bc9b490..9a05242 100644
--- a/app/controllers/plans_controller.rb
+++ b/app/controllers/plans_controller.rb
@@ -1,12 +1,13 @@
class PlansController < ApplicationController
#Uncomment the line below in order to add authentication to this page - users without permission will not be able to add new plans
#load_and_authorize_resource
+ after_action :verify_authorized
+
# GET /plans/1/edit
def edit
@plan = Plan.find(params[:id])
-
-
+ authorize @plan
if !user_signed_in? then
respond_to do |format|
format.html { redirect_to edit_user_registration_path }
@@ -22,6 +23,7 @@
# PUT /plans/1.json
def update
@plan = Plan.find(params[:id])
+ authorize @plan
if user_signed_in? && @plan.editable_by(current_user.id) then
respond_to do |format|
if @plan.update_attributes(params[:plan])
@@ -29,7 +31,6 @@
format.json { head :no_content }
else
format.html { render action: "edit" }
- format.json { render json: @plan.errors, status: :unprocessablne_entity }
end
end
else
@@ -37,9 +38,11 @@
end
end
- # GET /status/1.json
- def status
+ # GET /status/1.json
+ # only returns json, why is this here?
+ def status
@plan = Plan.find(params[:id])
+ authorize @plan
if user_signed_in? && @plan.readable_by(current_user.id) then
respond_to do |format|
format.json { render json: @plan.status }
@@ -51,6 +54,7 @@
def section_answers
@plan = Plan.find(params[:id])
+ authorize @plan
if user_signed_in? && @plan.readable_by(current_user.id) then
respond_to do |format|
format.json { render json: @plan.section_answers(params[:section_id]) }
@@ -62,6 +66,7 @@
def locked
@plan = Plan.find(params[:id])
+ authorize @plan
if !@plan.nil? && user_signed_in? && @plan.readable_by(current_user.id) then
respond_to do |format|
format.json { render json: @plan.locked(params[:section_id],current_user.id) }
@@ -73,14 +78,13 @@
def delete_recent_locks
@plan = Plan.find(params[:id])
+ authorize @plan
if user_signed_in? && @plan.editable_by(current_user.id) then
respond_to do |format|
if @plan.delete_recent_locks(current_user.id)
format.html { render action: "edit" }
- format.json { head :no_content }
else
format.html { render action: "edit" }
- format.json { render json: @plan.errors, status: :unprocessable_entity }
end
end
else
@@ -90,14 +94,13 @@
def unlock_all_sections
@plan = Plan.find(params[:id])
+ authorize @plan
if user_signed_in? && @plan.editable_by(current_user.id) then
respond_to do |format|
if @plan.unlock_all_sections(current_user.id)
format.html { render action: "edit" }
- format.json { head :no_content }
else
format.html { render action: "edit" }
- format.json { render json: @plan.errors, status: :unprocessable_entity }
end
end
else
@@ -107,11 +110,11 @@
def lock_section
@plan = Plan.find(params[:id])
+ authorize @plan
if user_signed_in? && @plan.editable_by(current_user.id) then
respond_to do |format|
if @plan.lock_section(params[:section_id], current_user.id)
format.html { render action: "edit" }
- format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @plan.errors, status: :unprocessable_entity }
@@ -124,14 +127,14 @@
def unlock_section
@plan = Plan.find(params[:id])
+ authorize @plan
if user_signed_in? && @plan.editable_by(current_user.id) then
respond_to do |format|
if @plan.unlock_section(params[:section_id], current_user.id)
format.html { render action: "edit" }
- format.json { head :no_content }
+
else
- format.html { render action: "edit" }
- format.json { render json: @plan.errors, status: :unprocessable_entity }
+ format.html { render action: "edit" }]
end
end
else
@@ -141,6 +144,7 @@
def answer
@plan = Plan.find(params[:id])
+ authorize @plan
if user_signed_in? && @plan.readable_by(current_user.id) then
respond_to do |format|
format.json { render json: @plan.answer(params[:q_id], false).to_json(:include => :options) }
@@ -152,6 +156,7 @@
def warning
@plan = Plan.find(params[:id])
+ authorize @plan
if user_signed_in? && @plan.readable_by(current_user.id) then
respond_to do |format|
format.json { render json: @plan.warning(params[:option_id]) }
@@ -163,6 +168,7 @@
def export
@plan = Plan.find(params[:id])
+ authorize @plan
if user_signed_in? && @plan.readable_by(current_user.id) then
@exported_plan = ExportedPlan.new.tap do |ep|
diff --git a/app/controllers/project_groups_controller.rb b/app/controllers/project_groups_controller.rb
index 426b842..2d81d39 100644
--- a/app/controllers/project_groups_controller.rb
+++ b/app/controllers/project_groups_controller.rb
@@ -1,7 +1,9 @@
class ProjectGroupsController < ApplicationController
+ after_action :verify_authorized
def create
@project_group = ProjectGroup.new(params[:project_group])
+ authorize @project_group
access_level = params[:project_group][:access_level].to_i
if access_level >= 3 then
@project_group.project_administrator = true
@@ -30,15 +32,12 @@
end
flash[:notice] = message
format.html { redirect_to :controller => 'projects', :action => 'share', :id => @project_group.project.slug }
- format.json { render json: @project_group, status: :created, location: @project_group }
else
format.html { render action: "new" }
- format.json { render json: @project_group.errors, status: :unprocessable_entity }
end
else
flash[:notice] = I18n.t('helpers.project.enter_email')
format.html { redirect_to :controller => 'projects', :action => 'share', :id => @project_group.project.slug }
- format.json { render json: @project_group, status: :created, location: @project_group }
end
end
else
@@ -49,6 +48,7 @@
def update
@project_group = ProjectGroup.find(params[:id])
+ authorize @project_group
access_level = params[:project_group][:access_level].to_i
if access_level >= 3 then
@project_group.project_administrator = true
@@ -66,10 +66,8 @@
flash[:notice] = I18n.t('helpers.project.sharing_updated')
UserMailer.permissions_change_notification(@project_group).deliver
format.html { redirect_to :controller => 'projects', :action => 'share', :id => @project_group.project.slug }
- format.json { head :no_content }
else
format.html { render action: "edit" }
- format.json { render json: @project_group.errors, status: :unprocessable_entity }
end
end
else
@@ -79,6 +77,7 @@
def destroy
@project_group = ProjectGroup.find(params[:id])
+ authorize @project_group
if (user_signed_in?) && @project_group.project.administerable_by(current_user.id) then
user = @project_group.user
project = @project_group.project
@@ -87,7 +86,6 @@
flash[:notice] = I18n.t('helpers.project.access_removed')
UserMailer.project_access_removed_notification(user, project).deliver
format.html { redirect_to :controller => 'projects', :action => 'share', :id => @project_group.project.slug }
- format.json { head :no_content }
end
else
render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 1e04277..f01d810 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -1,9 +1,11 @@
class ProjectsController < ApplicationController
before_filter :get_plan_list_columns, only: %i( index )
+ after_action :verify_authorized
# GET /projects
# GET /projects.json
def index
+ authorize Project
## TODO: Is this A magic String? the "Show_shib_link?" as we define it and users dont see cookies
if user_signed_in? then
if (current_user.shibboleth_id.nil? || current_user.shibboleth_id.length == 0) && !cookies[:show_shib_link].nil? && cookies[:show_shib_link] == "show_shib_link" then
@@ -15,7 +17,6 @@
respond_to do |format|
format.html # index.html.erb
- format.json { render json: @projects }
end
else
respond_to do |format|
@@ -28,6 +29,7 @@
# GET /projects/1.json
def show
@project = Project.find(params[:id])
+ authorize @project
@show_form = false
if params[:show_form] == "yes" then
@show_form = true
@@ -35,7 +37,6 @@
if user_signed_in? && @project.readable_by(current_user.id) then
respond_to do |format|
format.html # show.html.erb
- format.json { render json: @project }
end
elsif user_signed_in? then
respond_to do |format|
@@ -53,12 +54,16 @@
def new
if user_signed_in? then
@project = Project.new
+ authorize @project
@project.organisation = current_user.organisation
@funders = orgs_of_type(constant("organisation_types.funder"), true)
- @institutions = orgs_of_type(constant("organisation_types.institution"))
+ @templates = get_available_templates
+ @guidance_groups = get_available_guidance
+ @always_guidance = get_always_available_guidance
+ @institutions = orgs_of_type(constant("organisation_types.institution"))
+
respond_to do |format|
format.html # new.html.erb
- format.json { render json: @project }
end
else
respond_to do |format|
@@ -71,6 +76,7 @@
# Should this be removed?
def edit
@project = Project.find(params[:id])
+ authorize @project
if !user_signed_in? then
respond_to do |format|
format.html { redirect_to edit_user_registration_path }
@@ -84,6 +90,7 @@
def share
@project = Project.find(params[:id])
+ authorize @project
if !user_signed_in? then
respond_to do |format|
format.html { redirect_to edit_user_registration_path }
@@ -97,6 +104,7 @@
def export
@project = Project.find(params[:id])
+ authorize @project
if !user_signed_in? then
respond_to do |format|
format.html { redirect_to edit_user_registration_path }
@@ -114,7 +122,7 @@
def create
if user_signed_in? then
@project = Project.new(params[:project])
-
+ authorize @project
if @project.dmptemplate.nil? && params[:project][:funder_id] != "" then # this shouldn't be necessary - see setter for funder_id in project.rb
funder = Organisation.find(params[:project][:funder_id])
if funder.dmptemplates.count == 1 then
@@ -134,10 +142,8 @@
respond_to do |format|
if @project.save
format.html { redirect_to({:action => "show", :id => @project.slug, :show_form => "yes"}, {:notice => I18n.t('helpers.project.success')}) }
- format.json { render json: @project, status: :created, location: @project }
else
format.html { render action: "new" }
- format.json { render json: @project.errors, status: :unprocessable_entity }
end
end
else
@@ -149,17 +155,15 @@
# PUT /projects/1.json
def update
@project = Project.find(params[:id])
+ authorize @project
if user_signed_in? && @project.editable_by(current_user.id) then
-
if @project.update_attributes(params[:project])
respond_to do |format|
format.html { redirect_to({:action => "show", :id => @project.slug, notice: I18n.t('helpers.project.success_update') }) }
- format.json { head :no_content }
end
else
respond_to do |format|
format.html { render action: "edit" }
- format.json { render json: @project.errors, status: :unprocessable_entity }
end
end
else
@@ -171,18 +175,21 @@
# DELETE /projects/1.json
def destroy
@project = Project.find(params[:id])
+ authorize @project
if user_signed_in? && @project.editable_by(current_user.id) then
@project.destroy
respond_to do |format|
format.html { redirect_to projects_url }
- format.json { head :no_content }
end
else
render(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)
end
end
+ # returns to AJAX call from frontend
+ # difficult to secure as it passes through params, and dosent curate data based
+ # on what the user can "view" or is public
# GET /projects/possible_templates.json
def possible_templates
if !params[:funder].nil? && params[:funder] != "" && params[:funder] != "undefined" then
@@ -216,7 +223,11 @@
end
end
- def possible_guidance
+ # returns to AJAX call from frontend
+ # difficult to secure as it passes through params, and dosent curate data based
+ # on what the user can "view" or is public
+ def possible_guidance
+ authorize @project
if !params[:template].nil? && params[:template] != "" && params[:template] != "undefined" then
template = Dmptemplate.find(params[:template])
else
@@ -237,6 +248,7 @@
#subset guidance that belong to the institution
unless institution.nil? then
+ authorize Project
optional_gg = GuidanceGroup.where("optional_subset = ? && organisation_id = ?", true, institution.id)
optional_gg.each do|optional|
guidance_groups[optional.id] = optional.name
@@ -271,22 +283,75 @@
format.json { render json: guidance_groups.to_json }
end
end
-
+
private
+ def orgs_of_type(org_type_name, published_templates = false)
+ org_type = OrganisationType.find_by_name(org_type_name)
+ all_such_orgs = org_type.organisations
+ if published_templates then
+ with_published = Array.new
+ all_such_orgs.each do |o|
+ if o.published_templates.count > 0 then
+ with_published << o
+ end
+ end
+ return with_published.sort_by {|o| [o.sort_name, o.name] }
+ else
+ return all_such_orgs.sort_by {|o| [o.sort_name, o.name] }
+ end
+ end
+
+ # -----------------------------------------------------------
+ def get_available_templates
+ Dmptemplate.where(published: true)
+ end
+
+ # -----------------------------------------------------------
+ # Some guidance is always available to the user regardless of
+ # the template or institution.
+ #
+ # TODO: Reevaluate this. We should probably only do this for
+ # guidance groups who have guidance attached to themes
+ # -----------------------------------------------------------
+ def get_always_available_guidance
+ # Exclude Funders, Institutions, or children of Institutions
+ excluded_orgs = orgs_of_type(constant("organisation_types.funder")) +
+ orgs_of_type(constant("organisation_types.institution")) +
+ Organisation.orgs_with_parent_of_type(constant("organisation_types.institution"))
- def orgs_of_type(org_type_name, published_templates = false)
- org_type = OrganisationType.find_by_name(org_type_name)
- all_such_orgs = org_type.organisations
- if published_templates then
- with_published = Array.new
- all_such_orgs.each do |o|
- if o.published_templates.count > 0 then
- with_published << o
- end
- end
- return with_published.sort_by {|o| [o.sort_name, o.name] }
- else
- return all_such_orgs.sort_by {|o| [o.sort_name, o.name] }
- end
- end
+ GuidanceGroup.guidance_groups_excluding(excluded_orgs)
+ end
+
+ # -----------------------------------------------------------
+ # This is a simplified version of the old possible_guidance method
+ # above. It sends all possible guidance to the client instead of
+ # forcing the client to make ajax calls to change the available
+ # guidance list (that is now handled via JS clientside)
+ #
+ # TODO: Reevaluate whether or not this logic makes sense once the
+ # DB has been cleaned up
+ # -----------------------------------------------------------
+ def get_available_guidance
+ guidance_groups = []
+
+ #subset guidance that belong to an institution
+ optional_gg = GuidanceGroup.where("optional_subset = ? && organisation_id IS NOT NULL", true)
+ optional_gg.each do|optional|
+ guidance_groups << optional.id
+
+ optional.organisation.children.each do |o|
+ o.guidance_groups.each do |gg|
+ guidance_groups << gg.id
+ end
+ end
+ end
+
+ # If template belongs to a funder and is an optional_subset
+ optional_gg = GuidanceGroup.where("optional_subset = ? && organisation_id IN (?)", true, orgs_of_type(constant("organisation_types.funder")))
+ optional_gg.each do|optional|
+ guidance_groups << optional.id
+ end
+
+ GuidanceGroup.where(id: guidance_groups)
+ end
end
diff --git a/app/controllers/settings.rb b/app/controllers/settings.rb
index 443bf8a..612db61 100644
--- a/app/controllers/settings.rb
+++ b/app/controllers/settings.rb
@@ -1,7 +1,5 @@
module Settings
class SettingsController < ApplicationController
- before_filter do
- authorize! :manage_settings, current_user
- end
+
end
end
diff --git a/app/controllers/settings/plans_controller.rb b/app/controllers/settings/plans_controller.rb
index 82884e3..c9a4adb 100644
--- a/app/controllers/settings/plans_controller.rb
+++ b/app/controllers/settings/plans_controller.rb
@@ -2,17 +2,18 @@
class PlansController < SettingsController
before_filter :get_settings
+ after_action :verify_authorized
def show
+ authorize [:settings, plan]
respond_to do |format|
format.html
format.partial
- format.json { render json: settings_json }
end
end
def update
-
+ authorize [:settings, plan]
export_params = params[:export].try(:deep_symbolize_keys)
settings = plan.super_settings(:export).tap do |s|
@@ -29,7 +30,6 @@
if settings.save
respond_to do |format|
format.html { redirect_to(export_project_path(plan.project)) }
- format.json { render json: settings_json }
end
else
settings.formatting = nil
diff --git a/app/controllers/settings/projects_controller.rb b/app/controllers/settings/projects_controller.rb
index 5719f2c..5a2d48d 100644
--- a/app/controllers/settings/projects_controller.rb
+++ b/app/controllers/settings/projects_controller.rb
@@ -4,20 +4,22 @@
before_filter :get_plan_list_columns
before_filter :get_settings
+ after_action :verify_authorized
+
def show
+ authorize [:settings, Project]
respond_to do |format|
format.html
- format.json { render json: settings_json }
end
end
def update
+ authorize [:settings, Project]
columns = (params[:columns] || {})
if @settings.update_attributes(columns: columns)
respond_to do |format|
format.html { redirect_to(projects_path) }
- format.json { render json: settings_json }
end
else
render(action: :show) # Expect #show to display errors etc
diff --git a/app/controllers/themes_controller.rb b/app/controllers/themes_controller.rb
deleted file mode 100644
index 549e6b5..0000000
--- a/app/controllers/themes_controller.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-class ThemesController < ApplicationController
- # GET /themes
- # GET /themes.json
- def index
- @themes = Theme.all
-
- respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @themes }
- end
- end
-
- # GET /themes/1
- # GET /themes/1.json
- def show
- @theme = Theme.find(params[:id])
-
- respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @theme }
- end
- end
-
- # GET /themes/new
- # GET /themes/new.json
- def new
- @theme = Theme.new
-
- respond_to do |format|
- format.html # new.html.erb
- format.json { render json: @theme }
- end
- end
-
- # GET /themes/1/edit
- def edit
- @theme = Theme.find(params[:id])
- end
-
- # POST /themes
- # POST /themes.json
- def create
- @theme = Theme.new(params[:theme])
-
- respond_to do |format|
- if @theme.save
- format.html { redirect_to @theme, notice: I18n.t('admin.theme_created') }
- format.json { render json: @theme, status: :created, location: @theme }
- else
- format.html { render action: "new" }
- format.json { render json: @theme.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # PUT /themes/1
- # PUT /themes/1.json
- def update
- @theme = Theme.find(params[:id])
-
- respond_to do |format|
- if @theme.update_attributes(params[:theme])
- format.html { redirect_to @theme, notice: I18n.t('admin.theme_updated') }
- format.json { head :no_content }
- else
- format.html { render action: "edit" }
- format.json { render json: @theme.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # DELETE /themes/1
- # DELETE /themes/1.json
- def destroy
- @theme = Theme.find(params[:id])
- @theme.destroy
-
- respond_to do |format|
- format.html { redirect_to themes_url }
- format.json { head :no_content }
- end
- end
-end
diff --git a/app/controllers/user_org_roles_controller.rb b/app/controllers/user_org_roles_controller.rb
deleted file mode 100644
index c31867d..0000000
--- a/app/controllers/user_org_roles_controller.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-class UserOrgRolesController < ApplicationController
- # GET /user_org_roles
- # GET /user_org_roles.json
- def index
- @user_org_roles = UserOrgRole.all
-
- respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @user_org_roles }
- end
- end
-
- # GET /user_org_roles/1
- # GET /user_org_roles/1.json
- def show
- @user_org_role = UserOrgRole.find(params[:id])
-
- respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @user_org_role }
- end
- end
-
- # GET /user_org_roles/new
- # GET /user_org_roles/new.json
- def new
- @user_org_role = UserOrgRole.new
-
- respond_to do |format|
- format.html # new.html.erb
- format.json { render json: @user_org_role }
- end
- end
-
- # GET /user_org_roles/1/edit
- def edit
- @user_org_role = UserOrgRole.find(params[:id])
- end
-
- # POST /user_org_roles
- # POST /user_org_roles.json
- def create
- @user_org_role = UserOrgRole.new(params[:user_org_role])
-
- respond_to do |format|
- if @user_org_role.save
- format.html { redirect_to @user_org_role, notice: I18n.t('org_admin.user_org_created') }
- format.json { render json: @user_org_role, status: :created, location: @user_org_role }
- else
- format.html { render action: "new" }
- format.json { render json: @user_org_role.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # PUT /user_org_roles/1
- # PUT /user_org_roles/1.json
- def update
- @user_org_role = UserOrgRole.find(params[:id])
-
- respond_to do |format|
- if @user_org_role.update_attributes(params[:user_org_role])
- format.html { redirect_to @user_org_role, notice: I18n.t('org_admin.user_org_updated') }
- format.json { head :no_content }
- else
- format.html { render action: "edit" }
- format.json { render json: @user_org_role.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # DELETE /user_org_roles/1
- # DELETE /user_org_roles/1.json
- def destroy
- @user_org_role = UserOrgRole.find(params[:id])
- @user_org_role.destroy
-
- respond_to do |format|
- format.html { redirect_to user_org_roles_url }
- format.json { head :no_content }
- end
- end
-end
diff --git a/app/controllers/user_role_types_controller.rb b/app/controllers/user_role_types_controller.rb
deleted file mode 100644
index e45d86c..0000000
--- a/app/controllers/user_role_types_controller.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-class UserRoleTypesController < ApplicationController
- # GET /user_role_types
- # GET /user_role_types.json
- def index
- @user_role_types = UserRoleType.all
-
- respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @user_role_types }
- end
- end
-
- # GET /user_role_types/1
- # GET /user_role_types/1.json
- def show
- @user_role_type = UserRoleType.find(params[:id])
-
- respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @user_role_type }
- end
- end
-
- # GET /user_role_types/new
- # GET /user_role_types/new.json
- def new
- @user_role_type = UserRoleType.new
-
- respond_to do |format|
- format.html # new.html.erb
- format.json { render json: @user_role_type }
- end
- end
-
- # GET /user_role_types/1/edit
- def edit
- @user_role_type = UserRoleType.find(params[:id])
- end
-
- # POST /user_role_types
- # POST /user_role_types.json
- def create
- @user_role_type = UserRoleType.new(params[:user_role_type])
-
- respond_to do |format|
- if @user_role_type.save
- format.html { redirect_to @user_role_type, notice: I18n.t('admin.user_role_type_created') }
- format.json { render json: @user_role_type, status: :created, location: @user_role_type }
- else
- format.html { render action: "new" }
- format.json { render json: @user_role_type.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # PUT /user_role_types/1
- # PUT /user_role_types/1.json
- def update
- @user_role_type = UserRoleType.find(params[:id])
-
- respond_to do |format|
- if @user_role_type.update_attributes(params[:user_role_type])
- format.html { redirect_to @user_role_type, notice: I18n.t('admin.user_role_type_updated') }
- format.json { head :no_content }
- else
- format.html { render action: "edit" }
- format.json { render json: @user_role_type.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # DELETE /user_role_types/1
- # DELETE /user_role_types/1.json
- def destroy
- @user_role_type = UserRoleType.find(params[:id])
- @user_role_type.destroy
-
- respond_to do |format|
- format.html { redirect_to user_role_types_url }
- format.json { head :no_content }
- end
- end
-end
diff --git a/app/controllers/user_statuses_controller.rb b/app/controllers/user_statuses_controller.rb
deleted file mode 100644
index 0e19c5d..0000000
--- a/app/controllers/user_statuses_controller.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-class UserStatusesController < ApplicationController
- # GET /user_statuses
- # GET /user_statuses.json
- def index
- @user_statuses = UserStatus.all
-
- respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @user_statuses }
- end
- end
-
- # GET /user_statuses/1
- # GET /user_statuses/1.json
- def show
- @user_status = UserStatus.find(params[:id])
-
- respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @user_status }
- end
- end
-
- # GET /user_statuses/new
- # GET /user_statuses/new.json
- def new
- @user_status = UserStatus.new
-
- respond_to do |format|
- format.html # new.html.erb
- format.json { render json: @user_status }
- end
- end
-
- # GET /user_statuses/1/edit
- def edit
- @user_status = UserStatus.find(params[:id])
- end
-
- # POST /user_statuses
- # POST /user_statuses.json
- def create
- @user_status = UserStatus.new(params[:user_status])
-
- respond_to do |format|
- if @user_status.save
- format.html { redirect_to @user_status, notice: I18n.t('admin.user_status_created') }
- format.json { render json: @user_status, status: :created, location: @user_status }
- else
- format.html { render action: "new" }
- format.json { render json: @user_status.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # PUT /user_statuses/1
- # PUT /user_statuses/1.json
- def update
- @user_status = UserStatus.find(params[:id])
-
- respond_to do |format|
- if @user_status.update_attributes(params[:user_status])
- format.html { redirect_to @user_status, notice: I18n.t('admin.user_status_updated') }
- format.json { head :no_content }
- else
- format.html { render action: "edit" }
- format.json { render json: @user_status.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # DELETE /user_statuses/1
- # DELETE /user_statuses/1.json
- def destroy
- @user_status = UserStatus.find(params[:id])
- @user_status.destroy
-
- respond_to do |format|
- format.html { redirect_to user_statuses_url }
- format.json { head :no_content }
- end
- end
-end
diff --git a/app/controllers/user_types_controller.rb b/app/controllers/user_types_controller.rb
deleted file mode 100644
index 565bdf2..0000000
--- a/app/controllers/user_types_controller.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-class UserTypesController < ApplicationController
- # GET /user_types
- # GET /user_types.json
- def index
- @user_types = UserType.all
-
- respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @user_types }
- end
- end
-
- # GET /user_types/1
- # GET /user_types/1.json
- def show
- @user_type = UserType.find(params[:id])
-
- respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @user_type }
- end
- end
-
- # GET /user_types/new
- # GET /user_types/new.json
- def new
- @user_type = UserType.new
-
- respond_to do |format|
- format.html # new.html.erb
- format.json { render json: @user_type }
- end
- end
-
- # GET /user_types/1/edit
- def edit
- @user_type = UserType.find(params[:id])
- end
-
- # POST /user_types
- # POST /user_types.json
- def create
- @user_type = UserType.new(params[:user_type])
-
- respond_to do |format|
- if @user_type.save
- format.html { redirect_to @user_type, notice: I18n.t('admin.user_type_updated') }
- format.json { render json: @user_type, status: :created, location: @user_type }
- else
- format.html { render action: "new" }
- format.json { render json: @user_type.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # PUT /user_types/1
- # PUT /user_types/1.json
- def update
- @user_type = UserType.find(params[:id])
-
- respond_to do |format|
- if @user_type.update_attributes(params[:user_type])
- format.html { redirect_to @user_type, notice: I18n.t('admin.user_type_updated') }
- format.json { head :no_content }
- else
- format.html { render action: "edit" }
- format.json { render json: @user_type.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # DELETE /user_types/1
- # DELETE /user_types/1.json
- def destroy
- @user_type = UserType.find(params[:id])
- @user_type.destroy
-
- respond_to do |format|
- format.html { redirect_to user_types_url }
- format.json { head :no_content }
- end
- end
-end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 530bf0f..636c44a 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,83 +1,11 @@
class UsersController < ApplicationController
-
- # GET /users/1
- # GET /users/1.json
- def show
- @user = User.find(params[:id])
-
- respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @user }
- end
- end
-
- # GET /users/new
- # GET /users/new.json
- def new
- @user = User.new
-
- respond_to do |format|
- format.html # new.html.erb
- format.json { render json: @user }
- end
- end
-
- # GET /users/1/edit
- def edit
- @user = User.find(params[:id])
- end
-
- # POST /users
- # POST /users.json
- def create
- @user = User.new(params[:user])
-
- respond_to do |format|
- if @user.save
- format.html { redirect_to @user, notice: I18n.t('admin.user_created') }
- format.json { render json: @user, status: :created, location: @user }
- else
- format.html { render action: "new" }
- format.json { render json: @user.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # PUT /users/1
- # PUT /users/1.json
- def update
- @user = User.find(params[:id])
-
- respond_to do |format|
- if @user.update_attributes(params[:user])
- format.html { redirect_to({:controller=> "projects", :action => "new"}, {:notice => I18n.t('helpers.project.create_success') }) }
- format.json { head :no_content }
- else
- format.html { render action: "edit" }
- format.json { render json: @user.errors, status: :unprocessable_entity }
- end
- end
- end
-
-
- # DELETE /users/1
- # DELETE /users/1.json
- def destroy
- @user = User.find(params[:id])
- @user.destroy
-
- respond_to do |format|
- format.html { redirect_to users_url }
- format.json { head :no_content }
- end
- end
+ after_action :verify_authorized
def admin_index
authorize User
@users = current_user.organisation.users.includes(:roles, :project_groups)
respond_to do |format|
format.html # index.html.erb
- format.json { render json: @organisation_users }
end
end
@@ -113,7 +41,6 @@
@user.save!
respond_to do |format|
format.html { redirect_to({controller: 'users', action: 'admin_index'}, {notice: I18n.t('helpers.success')})}
- format.json { head :no_content }
end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 1adb49e..56f99a5 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -34,4 +34,8 @@
content_tag(:a, name, html_options.merge(:href => href, :onclick => onclick))
end
+
+ def hash_to_json_object(obj_name, hash)
+ "".html_safe
+ end
end
diff --git a/app/models/guidance_group.rb b/app/models/guidance_group.rb
index c5d5c24..1468c19 100644
--- a/app/models/guidance_group.rb
+++ b/app/models/guidance_group.rb
@@ -1,18 +1,18 @@
class GuidanceGroup < ActiveRecord::Base
include GlobalHelpers
- #associations between tables
- belongs_to :organisation
+ #associations between tables
+ belongs_to :organisation
- has_and_belongs_to_many :guidances, join_table: "guidance_in_group"
+ has_and_belongs_to_many :guidances, join_table: "guidance_in_group"
- has_and_belongs_to_many :projects, join_table: "project_guidance"
- has_and_belongs_to_many :dmptemplates, join_table: "dmptemplates_guidance_groups"
+ has_and_belongs_to_many :projects, join_table: "project_guidance"
+ has_and_belongs_to_many :dmptemplates, join_table: "dmptemplates_guidance_groups"
- accepts_nested_attributes_for :dmptemplates
+ accepts_nested_attributes_for :dmptemplates
- attr_accessible :organisation_id, :name, :optional_subset, :published, :as => [:default, :admin]
- attr_accessible :dmptemplate_ids, :as => [:default, :admin]
+ attr_accessible :organisation_id, :name, :optional_subset, :published, :as => [:default, :admin]
+ attr_accessible :dmptemplate_ids, :as => [:default, :admin]
##
# Converts a guidance group to a string containing the display name
diff --git a/app/models/organisation.rb b/app/models/organisation.rb
index 4db9796..488debf 100644
--- a/app/models/organisation.rb
+++ b/app/models/organisation.rb
@@ -1,5 +1,3 @@
-#require 'validators/email_validator'
-
class Organisation < ActiveRecord::Base
include GlobalHelpers
diff --git a/app/models/organisation_type.rb b/app/models/organisation_type.rb
index c8e0edc..d26464b 100644
--- a/app/models/organisation_type.rb
+++ b/app/models/organisation_type.rb
@@ -1,5 +1,5 @@
class OrganisationType < ActiveRecord::Base
- attr_accessible :description, :name, :as => [:default, :admin]
+ attr_accessible :description, :organisations, :name, :as => [:default, :admin]
has_many :organisations
diff --git a/app/models/user.rb b/app/models/user.rb
index 351e7be..6921a36 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -119,7 +119,7 @@
return nil
end
end
-
+
##
# returns the organisation of the user or nil
#
diff --git a/app/policies/answer_policy.rb b/app/policies/answer_policy.rb
new file mode 100644
index 0000000..61f6989
--- /dev/null
+++ b/app/policies/answer_policy.rb
@@ -0,0 +1,15 @@
+class AnswerPolicy < ApplicationPolicy
+ attr_reader :user
+ attr_reader :answer
+
+ def initialize(user, answer)
+ raise Pundit::NotAuthorizedError, "must be logged in" unless user
+ @user = user
+ @answer = answer
+ end
+
+ def create?
+ @answer.plan.editable_by(@user.id)
+ end
+
+end
\ No newline at end of file
diff --git a/app/policies/application_policy.rb b/app/policies/application_policy.rb
index ea84308..de9b7ba 100644
--- a/app/policies/application_policy.rb
+++ b/app/policies/application_policy.rb
@@ -9,7 +9,7 @@
end
def index?
- false
+ true
end
def show?
@@ -17,7 +17,7 @@
end
def create?
- false
+ true
end
def new?
@@ -25,7 +25,7 @@
end
def update?
- false
+ true
end
def edit?
@@ -33,7 +33,7 @@
end
def destroy?
- false
+ true
end
def scope
diff --git a/app/policies/comment_policy.rb b/app/policies/comment_policy.rb
new file mode 100644
index 0000000..570c0a1
--- /dev/null
+++ b/app/policies/comment_policy.rb
@@ -0,0 +1,23 @@
+class CommentPolicy < ApplicationPolicy
+ attr_reader :user
+ attr_reader :comment
+
+ def initialize(user, comment)
+ raise Pundit::NotAuthorizedError, "must be logged in" unless user
+ @user = user
+ @comment = comment
+ end
+
+ def create?
+ Plan.find(@comment.plan_id).readable_by(@user.id)
+ end
+
+ def update?
+ Plan.find(@comment.plan_id).readable_by(@user.id)
+ end
+
+ def archive?
+ Plan.find(@comment.plan_id).readable_by(@user.id)
+ end
+
+end
\ No newline at end of file
diff --git a/app/policies/dmptemplate_policy.rb b/app/policies/dmptemplate_policy.rb
index ea17c40..c2dbe91 100644
--- a/app/policies/dmptemplate_policy.rb
+++ b/app/policies/dmptemplate_policy.rb
@@ -12,11 +12,11 @@
end
def admin_template?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_update?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_new?
@@ -24,95 +24,95 @@
end
def admin_create?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_destroy?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_phase?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_previewphase?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_addphase?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_createphase?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_updatephase?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_destroyphase?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_updateversion?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_cloneversion?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_destroyversion?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_createsection?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_updatesection?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_destroysection?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_createquestion?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_updatequestion?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_destroyquestion?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_createsuggestedanswer?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_updatesuggestedanswer?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_destroysuggestedanswer?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_createguidance?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_updateguidance?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
def admin_destroyguidance?
- user.can_modify_templates? && (dmptemplate.organisation_id == user.organisation_id)
+ user.can_modify_templates? #&& (dmptemplate.organisation_id == user.organisation_id)
end
class Scope < Scope
diff --git a/app/policies/organisation_policy.rb b/app/policies/organisation_policy.rb
index 4326458..677912c 100644
--- a/app/policies/organisation_policy.rb
+++ b/app/policies/organisation_policy.rb
@@ -19,4 +19,16 @@
user.can_modify_org_details? && (user.organisaiton_id == organisation.id)
end
+ def parent?
+ true
+ end
+
+ def children?
+ true
+ end
+
+ def templates?
+ true
+ end
+
end
\ No newline at end of file
diff --git a/app/policies/plan_policy.rb b/app/policies/plan_policy.rb
new file mode 100644
index 0000000..2d4d08a
--- /dev/null
+++ b/app/policies/plan_policy.rb
@@ -0,0 +1,58 @@
+class PlanPolicy < ApplicationPolicy
+ attr_reader :user
+ attr_reader :plan
+
+ def initialize(user, plan)
+ raise Pundit::NotAuthorizedError, "must be logged in" unless user
+ @user = user
+ @plan = plan
+ end
+
+ def edit?
+ @plan.editable_by(@user.id)
+ end
+
+ def export?
+ @plan.readable_by(@user.id)
+ end
+
+ def update?
+ @plan.editable_by(@user.id)
+ end
+
+ def status?
+ @plan.readable_by(@user.id)
+ end
+
+ def section_answers?
+ @plan.readable_by(@user.id)
+ end
+
+ def locked?
+ @plan.readable_by(@user.id)
+ end
+
+ def delete_recent_locks?
+ @plan.editable_by(@user.id)
+ end
+
+ def unlock_all_sections?
+ @plan.editable_by(@user.id)
+ end
+
+ def lock_section?
+ @plan.editable_by(@user.id)
+ end
+
+ def unlock_section?
+ @plan.editable_by(@user.id)
+ end
+
+ def answer?
+ @plan.readable_by(@user.id)
+ end
+
+ def warning?
+ @plan.readable_by(@user.id)
+ end
+end
\ No newline at end of file
diff --git a/app/policies/project_group_policy.rb b/app/policies/project_group_policy.rb
new file mode 100644
index 0000000..595687e
--- /dev/null
+++ b/app/policies/project_group_policy.rb
@@ -0,0 +1,22 @@
+class ProjectGroupPolicy < ApplicationPolicy
+ attr_reader :user
+ attr_reader :project_group
+
+ def initialize(user, project_group)
+ raise Pundit::NotAuthorizedError, "must be logged in" unless user
+ @user = user
+ @project_group = project_group
+ end
+
+ def create?
+ @project_group.project.administerable_by(@user.id)
+ end
+
+ def update?
+ @project_group.project.administerable_by(@user.id)
+ end
+
+ def destroy?
+ @project_group.project.administerable_by(@user.id)
+ end
+end
\ No newline at end of file
diff --git a/app/policies/project_policy.rb b/app/policies/project_policy.rb
new file mode 100644
index 0000000..60c76fd
--- /dev/null
+++ b/app/policies/project_policy.rb
@@ -0,0 +1,42 @@
+class ProjectPolicy < ApplicationPolicy
+ attr_reader :user
+ attr_reader :project
+
+ def initialize(user, project)
+ raise Pundit::NotAuthorizedError, "must be logged in" unless user
+ @user = user
+ @project = project
+ end
+
+ def show?
+ @project.readable_by(@user.id)
+ end
+
+ def edit?
+ @project.editable_by(@user.id)
+ end
+
+ def share?
+ @project.editable_by(@user.id)
+ end
+
+ def export?
+ @project.readable_by(@user.id)
+ end
+
+ def update?
+ @project.editable_by(@user.id)
+ end
+
+ def destroy?
+ @project.editable_by(@user.id)
+ end
+
+ def possible_templates?
+ true
+ end
+
+ def possible_guidance?
+ true
+ end
+end
\ No newline at end of file
diff --git a/app/policies/settings/plan_policy.rb b/app/policies/settings/plan_policy.rb
new file mode 100644
index 0000000..f8bd066
--- /dev/null
+++ b/app/policies/settings/plan_policy.rb
@@ -0,0 +1,20 @@
+class Settings::PlanPolicy < ApplicationPolicy
+
+ attr_reader :user
+ attr_reader :plan
+
+ def initialize(user, plan)
+ raise Pundit::NotAuthorizedError, "must be logged in" unless user
+ @user = user
+ @plan = plan
+ end
+
+ def show?
+ @plan.readable_by(@user.id)
+ end
+
+ def update?
+ @plan.editable_by(@user.id)
+ end
+
+end
\ No newline at end of file
diff --git a/app/policies/settings/project_policy.rb b/app/policies/settings/project_policy.rb
new file mode 100644
index 0000000..08c333f
--- /dev/null
+++ b/app/policies/settings/project_policy.rb
@@ -0,0 +1,24 @@
+class Settings::ProjectPolicy < ApplicationPolicy
+ # this is the policy for app/controllers/settings/projects_controller.rb
+
+ attr_reader :user
+ attr_reader :projects
+
+ def initialize(user, settings)
+ raise Pundit::NotAuthorizedError, "must be logged in" unless user
+ @user = user
+ @settings = settings
+ end
+
+ # for this controller, we allow all actions as the "settings" object
+ # is curated by rails based on user, not on a passed param
+
+ def show?
+ true
+ end
+
+ def update?
+ true
+ end
+
+end
\ No newline at end of file
diff --git a/app/views/dmptemplates/_show_phases_sections.html.erb b/app/views/dmptemplates/_show_phases_sections.html.erb
index 6822565..19c603a 100644
--- a/app/views/dmptemplates/_show_phases_sections.html.erb
+++ b/app/views/dmptemplates/_show_phases_sections.html.erb
@@ -53,7 +53,7 @@
<% questions.each do |ques|%>
- - <%= ques.text %>
+ - <%= raw ques.text %>
<%end%>
@@ -70,4 +70,4 @@
<%end%>
-
\ No newline at end of file
+
diff --git a/app/views/layouts/_dmponline_signin_signout.html.erb b/app/views/layouts/_dmponline_signin_signout.html.erb
index 544aa16..e7ff108 100644
--- a/app/views/layouts/_dmponline_signin_signout.html.erb
+++ b/app/views/layouts/_dmponline_signin_signout.html.erb
@@ -12,7 +12,7 @@
<%= link_to t("helpers.admin_area"), "/admin", :class => "signIn_dropdown_link" %>
<%end%>
<% if current_user.can_org_admin? %>
- <%= link_to t("org_admin.admin_area"), admin_index_dmptemplate_path(current_user.organisation_id), :class => "signIn_dropdown_link" %>
+<%= link_to t("org_admin.admin_area"), admin_index_dmptemplate_path(current_user.organisation_id), :class => "signIn_dropdown_link" %>
<%end%>
<%= link_to t("helpers.sign_out"), destroy_user_session_path, method: :delete, :class => "signIn_dropdown_link" %>
diff --git a/app/views/organisations/admin_show.html.erb b/app/views/organisations/admin_show.html.erb
index 6c32864..f853368 100644
--- a/app/views/organisations/admin_show.html.erb
+++ b/app/views/organisations/admin_show.html.erb
@@ -75,4 +75,4 @@
-
+
\ No newline at end of file
diff --git a/app/views/projects/_dropdowns_new_project.html.erb b/app/views/projects/_dropdowns_new_project.html.erb
index 4adc75e..241753b 100644
--- a/app/views/projects/_dropdowns_new_project.html.erb
+++ b/app/views/projects/_dropdowns_new_project.html.erb
@@ -11,7 +11,6 @@
-
<%= f.input :funder_id, :as => :select, :collection => @funders, :label => t('helpers.project.create_page.funders_question'), :input_html => { :multiple => false, :class => ["select2", "select2-container"] }, :include_blank => constant("organisation_types.funder") %>
@@ -30,7 +29,7 @@
- <%= f.input :institution_id, :as => :select, :collection => @institutions, :label => t('helpers.project.create_page.institution_question'), :input_html => { :multiple => false, :class => "typeahead" }, :include_blank => constant("organisation_types.organisation") %>
+ <%= f.input :institution_id, :as => :select, :collection => @institutions, :label => t('helpers.project.create_page.institution_question'), :input_html => { :multiple => false, :class => ["select2", "select2-container", "typeahead"] }, :include_blank => constant("organisation_types.organisation") %>
- <%= f.input :dmptemplate, :as => :select, :collection => Dmptemplate.where(published: 1), :label => t('helpers.project.choose_template'), :input_html => { :multiple => false, :class => "typeahead" } %>
-
- <%= t('helpers.project.multi_templates') %>
-
+
+
+ <%= t('helpers.project.choose_template') %>
+
+
+
+ <%= t('helpers.project.multi_templates') %>
+
+
@@ -56,6 +60,48 @@
+
+ <% #
+ # The following JSON arrays are used to build/filter the contents of
+ # the select2 dropdown box for dmptemplates and the checkboxes for
+ # the guidance group selections
+ # (they are referenced in /app/assets/javascripts/projects.js)
+ # %>
+
+ <%= hash_to_json_object('funders',
+ @funders.collect{ |inst|
+ {'id': inst.id,
+ 'text': inst.name}
+ }) %>
+
+ <%= hash_to_json_object('institutions',
+ @institutions.collect{ |inst|
+ {'id': inst.id,
+ 'text': inst.name,
+ 'default': (current_user.organisation_id == inst.id)}
+ }) %>
+
+ <%= hash_to_json_object('templates',
+ @templates.collect{ |tmplt|
+ {'organisation': tmplt.organisation_id,
+ 'id': tmplt.id,
+ 'text': tmplt.title}
+ }) %>
+
+ <%= hash_to_json_object('guidance_for_template_or_organisation',
+ @guidance_groups.collect{ |grp|
+ {'organisation': grp.organisation_id,
+ 'templates': grp.dmptemplates.collect{ |t| t.id },
+ 'id': grp.id,
+ 'text': grp.name}
+ }) %>
+
+ <%= hash_to_json_object('guidance_always_available',
+ @always_guidance.collect{ |grp|
+ {'id': grp.id,
+ 'text': grp.name}
+ }) %>
+
<% end %>
<%= f.actions do %>
diff --git a/config/initializers/dragonfly.rb b/config/initializers/dragonfly.rb
index 7e74f09..bfaa4e5 100644
--- a/config/initializers/dragonfly.rb
+++ b/config/initializers/dragonfly.rb
@@ -23,4 +23,4 @@
if defined?(ActiveRecord::Base)
ActiveRecord::Base.extend Dragonfly::Model
ActiveRecord::Base.extend Dragonfly::Model::Validations
-end
+end
\ No newline at end of file
diff --git a/config/locales/de.yml b/config/locales/de.yml
index 4ff6706..f853366 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -804,4 +804,73 @@
"
footer:
- terms_of_use: "
Universität Kiel , Kiel, SH, Deutschland Nutzungsbedingungen
"
\ No newline at end of file
+ terms_of_use: "
Universität Kiel , Kiel, SH, Deutschland Nutzungsbedingungen
"
+
+ js:
+ question_text_empty: 'Question text is empty, please enter your question.'
+ add_guidance_text: "add guidance text"
+ select_question: "select a question"
+ select_at_least_one_theme: "select at least one theme"
+ select_guidance_group: "select a guidance group"
+ enter_up_to: "Please only enter up to 165 characters, you have used"
+ if_using_url_try: "If you are entering an URL try to use something like http://tinyurl.com/ to make it smaller."
+ you_have_unsaved_in_sections: 'You have unsaved answers in the following sections:\n'
+
+ custom_devise:
+ resend_confirmation: "Resend confirmation instructions"
+ welcome_to_DMP: "Welcome to %{application_name}"
+ thank_you_and_confirm: "Thank you for registering at %{application_name}. Please confirm your email address:"
+ click_to_confirm: "Click here to confirm your account"
+ 1st_part_copy: "(or copy"
+ 2nd_part_copy: "into your browser)."
+ colleague_invited_you: "A colleague has invited you to contribute to their Data Management Plan at"
+ click_to_accept: "Click here to accept the invitation"
+ ignore_wont_be_created: "
If you don't want to accept the invitation, please ignore this email.
+ Your account won't be created until you access the link above and set your password.
"
+ 1st_part_change_password: "Someone has requested a link to change your"
+ 2nd_part_change_password: "password. You can do this through the link below."
+ ignore_password_wont_be_changed: "
If you didn't request this, please ignore this email.
+
Your password won't change until you access the link above and create a new one.
"
+ hello: "Hello"
+ 1st_part_locked: "Your "
+ 2nd_part_locked: " account has been locked due to an excessive number of unsuccessful sign in attempts."
+ click_to_unlock: "Click the link below to unlock your account:"
+ unlock: 'Unlock my account'
+ waiting_for_confirmation: "Currently waiting confirmation for: "
+ resend_unlock: "Resend unlock instructions"
+
+ api:
+ bad_credentials: '{"Error":"Bad credentials"}'
+ org_dosent_exist: '{"Error":"Organisation does not exist"}'
+ org_not_funder: '{"Error":"Organisation specified is not a funder"}'
+ org_multiple_templates: '{"Error":"Organisation has more than one template and template name unspecified or invalid"}'
+ no_auth_for_endpoint: '{"Error":"You do not have authorisation to view this endpoint"}'
+ bad_resource: '{"Error":"You do not have authorisation to view this resource"}'
+
+ magic_strings:
+ organisation_types:
+ funder: 'Funder'
+ organisation: 'Organisation'
+ project: 'Project'
+ institution: 'Institution'
+ research_institute: 'Research Institute'
+ template: 'Template'
+ managing_organisation: 'Digital Curation Center'
+ user_role_types:
+ super_admin: 'admin'
+ organisational_admin: 'org_admin'
+ user: 'user'
+ add_organisations: 'add_organisations'
+ change_org_affiliation: 'change_org_affiliation'
+ grant_permissions: 'grant_permissions'
+ modify_templates: 'modify_templates'
+ modify_guidance: 'modify_guidance'
+ use_api: 'use_api'
+ change_org_details: 'change_org_detials'
+ grant_api_to_orgs: 'grant_api_to_orgs'
+ api_endpoint_types:
+ guidances: 'guidances'
+ plans: 'plans'
+ templates: 'templates'
+ statistics: 'statistics'
+ languages:
diff --git a/config/locales/en-US.yml b/config/locales/en-US.yml
index 8f7d952..2a1fdd7 100644
--- a/config/locales/en-US.yml
+++ b/config/locales/en-US.yml
@@ -930,4 +930,32 @@
org_not_funder: '{"Error":"Organization specified is not a funder"}'
org_multiple_templates: '{"Error":"Organization has more than one template and template name unspecified or invalid"}'
no_auth_for_endpoint: '{"Error":"You do not have authorisation to view this endpoint"}'
- bad_resource: '{"Error":"You do not have authorisation to view this resource"}'
\ No newline at end of file
+ bad_resource: '{"Error":"You do not have authorisation to view this resource"}'
+
+ magic_strings:
+ organisation_types:
+ funder: 'Funder'
+ organisation: 'Organisation'
+ project: 'Project'
+ institution: 'Institution'
+ research_institute: 'Research Institute'
+ template: 'Template'
+ managing_organisation: 'Digital Curation Center'
+ user_role_types:
+ super_admin: 'admin'
+ organisational_admin: 'org_admin'
+ user: 'user'
+ add_organisations: 'add_organisations'
+ change_org_affiliation: 'change_org_affiliation'
+ grant_permissions: 'grant_permissions'
+ modify_templates: 'modify_templates'
+ modify_guidance: 'modify_guidance'
+ use_api: 'use_api'
+ change_org_details: 'change_org_detials'
+ grant_api_to_orgs: 'grant_api_to_orgs'
+ api_endpoint_types:
+ guidances: 'guidances'
+ plans: 'plans'
+ templates: 'templates'
+ statistics: 'statistics'
+ languages:
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index 4b6f19e..42749c7 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -790,4 +790,73 @@
-
En utilisant l'outil, vous comprenez et acceptez ces conditions.
"
\ No newline at end of file
+
En utilisant l'outil, vous comprenez et acceptez ces conditions.
"
+
+ js:
+ question_text_empty: 'Question text is empty, please enter your question.'
+ add_guidance_text: "add guidance text"
+ select_question: "select a question"
+ select_at_least_one_theme: "select at least one theme"
+ select_guidance_group: "select a guidance group"
+ enter_up_to: "Please only enter up to 165 characters, you have used"
+ if_using_url_try: "If you are entering an URL try to use something like http://tinyurl.com/ to make it smaller."
+ you_have_unsaved_in_sections: 'You have unsaved answers in the following sections:\n'
+
+ custom_devise:
+ resend_confirmation: "Resend confirmation instructions"
+ welcome_to_DMP: "Welcome to %{application_name}"
+ thank_you_and_confirm: "Thank you for registering at %{application_name}. Please confirm your email address:"
+ click_to_confirm: "Click here to confirm your account"
+ 1st_part_copy: "(or copy"
+ 2nd_part_copy: "into your browser)."
+ colleague_invited_you: "A colleague has invited you to contribute to their Data Management Plan at"
+ click_to_accept: "Click here to accept the invitation"
+ ignore_wont_be_created: "If you don't want to accept the invitation, please ignore this email.
+ Your account won't be created until you access the link above and set your password.
"
+ 1st_part_change_password: "Someone has requested a link to change your"
+ 2nd_part_change_password: "password. You can do this through the link below."
+ ignore_password_wont_be_changed: "If you didn't request this, please ignore this email.
+ Your password won't change until you access the link above and create a new one.
"
+ hello: "Hello"
+ 1st_part_locked: "Your "
+ 2nd_part_locked: " account has been locked due to an excessive number of unsuccessful sign in attempts."
+ click_to_unlock: "Click the link below to unlock your account:"
+ unlock: 'Unlock my account'
+ waiting_for_confirmation: "Currently waiting confirmation for: "
+ resend_unlock: "Resend unlock instructions"
+
+ api:
+ bad_credentials: '{"Error":"Bad credentials"}'
+ org_dosent_exist: '{"Error":"Organisation does not exist"}'
+ org_not_funder: '{"Error":"Organisation specified is not a funder"}'
+ org_multiple_templates: '{"Error":"Organisation has more than one template and template name unspecified or invalid"}'
+ no_auth_for_endpoint: '{"Error":"You do not have authorisation to view this endpoint"}'
+ bad_resource: '{"Error":"You do not have authorisation to view this resource"}'
+
+ magic_strings:
+ organisation_types:
+ funder: 'Funder'
+ organisation: 'Organisation'
+ project: 'Project'
+ institution: 'Institution'
+ research_institute: 'Research Institute'
+ template: 'Template'
+ managing_organisation: 'Digital Curation Center'
+ user_role_types:
+ super_admin: 'admin'
+ organisational_admin: 'org_admin'
+ user: 'user'
+ add_organisations: 'add_organisations'
+ change_org_affiliation: 'change_org_affiliation'
+ grant_permissions: 'grant_permissions'
+ modify_templates: 'modify_templates'
+ modify_guidance: 'modify_guidance'
+ use_api: 'use_api'
+ change_org_details: 'change_org_detials'
+ grant_api_to_orgs: 'grant_api_to_orgs'
+ api_endpoint_types:
+ guidances: 'guidances'
+ plans: 'plans'
+ templates: 'templates'
+ statistics: 'statistics'
+ languages:
diff --git a/config/routes.rb b/config/routes.rb
index 1d59a2b..78c801a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -42,7 +42,7 @@
#post 'contact_form' => 'contacts', as: 'localized_contact_creation'
#get 'contact_form' => 'contacts#new', as: 'localized_contact_form'
- resources :organisations, :path => 'org/admin' do
+ resources :organisations, :path => 'org/admin', only: [] do
member do
get 'children'
get 'templates'
@@ -52,7 +52,7 @@
end
end
- resources :guidances, :path => 'org/admin/guidance' do
+ resources :guidances, :path => 'org/admin/guidance', only: [] do
member do
get 'admin_show'
get 'admin_index'
@@ -62,14 +62,14 @@
post 'admin_create'
put 'admin_update'
- get 'update_phases', :as => 'update_phases'
- get 'update_versions', :as => 'update_versions'
- get 'update_sections', :as => 'update_sections'
- get 'update_questions', :as => 'update_questions'
+ get 'update_phases'
+ get 'update_versions'
+ get 'update_sections'
+ get 'update_questions'
end
end
- resources :guidance_groups, :path => 'org/admin/guidancegroup' do
+ resources :guidance_groups, :path => 'org/admin/guidancegroup', only: [] do
member do
get 'admin_show'
get 'admin_new'
@@ -80,11 +80,7 @@
end
end
- #resource :organisation
-
- #resources :splash_logs
-
- resources :dmptemplates, :path => 'org/admin/templates' do
+ resources :dmptemplates, :path => 'org/admin/templates', only: [] do
member do
get 'admin_index'
get 'admin_template'
@@ -113,25 +109,16 @@
end
end
- resources :phases
- resources :versions
- resources :sections
- resources :questions
- resources :question_themes
+ resources :answers, only: :create
-
- resources :themes
-
- resources :answers
- resources :plan_sections
- resources :comments do
+ resources :comments, only: [:create, :update] do
member do
put 'archive'
end
end
resources :projects do
- resources :plans do
+ resources :plans , only: [:edit, :update] do
member do
get 'status'
get 'locked'
@@ -151,7 +138,6 @@
get 'share'
get 'export'
post 'invite'
- #post 'create'
end
collection do
get 'possible_templates'
@@ -159,26 +145,11 @@
end
end
- resources :project_partners
- resources :project_groups
-
- resources :users
- resources :user_statuses
- resources :user_types
-
- resources :user_role_types
- resources :user_org_roles
-
-
- resources :organisation_types
- resources :pages
-
- resources :file_types
- resources :file_uploads
+ resources :project_groups, only: [:create, :update, :destroy]
namespace :settings do
- resource :projects
- resources :plans
+ resource :projects, only: [:show, :update]
+ resources :plans, only: [:show, :update]
end
resources :token_permission_types, only: [:index]
@@ -199,8 +170,6 @@
end
end
- get '/api' => redirect('/swagger/dist/index.html?url=/apidocs/api-docs.json')
-
# The priority is based upon order of creation:
# first created -> highest priority.