diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-12-05 20:31:27 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-12-05 20:31:27 -0500 |
commit | e9fedf3e5cd63aea4da7a71f6647ee427c62fa49 (patch) | |
tree | abc2de5aebace4a2d7c94805552264dab6b10bc7 /assets/js/src | |
parent | 346b8312e5ac877ce3192c2db3a26b500018bbb5 (diff) |
Rewrite of the authentication and authorization system
Diffstat (limited to 'assets/js/src')
-rw-r--r-- | assets/js/src/App.js | 29 | ||||
-rw-r--r-- | assets/js/src/Project.js | 18 |
2 files changed, 36 insertions, 11 deletions
diff --git a/assets/js/src/App.js b/assets/js/src/App.js index ca94661d..0102ada4 100644 --- a/assets/js/src/App.js +++ b/assets/js/src/App.js @@ -8,6 +8,7 @@ function App() { this.tooltip = new Tooltip(this); this.popover = new Popover(this); this.task = new Task(); + this.project = new Project(); this.keyboardShortcuts(); this.chosen(); this.poll(); @@ -29,6 +30,7 @@ function App() { } App.prototype.listen = function() { + this.project.listen(); this.popover.listen(); this.markdown.listen(); this.sidebar.listen(); @@ -38,7 +40,7 @@ App.prototype.listen = function() { this.task.listen(); this.swimlane.listen(); this.search.focus(); - this.taskAutoComplete(); + this.autoComplete(); this.datePicker(); this.focus(); }; @@ -127,25 +129,30 @@ App.prototype.datePicker = function() { }); }; -App.prototype.taskAutoComplete = function() { - // Task auto-completion - if ($(".task-autocomplete").length) { +App.prototype.autoComplete = function() { + $(".autocomplete").each(function() { + var input = $(this); + var field = input.data("dst-field"); + var extraField = input.data("dst-extra-field"); - if ($('.opposite_task_id').val() == '') { - $(".task-autocomplete").parent().find("input[type=submit]").attr('disabled','disabled'); + if ($('#form-' + field).val() == '') { + input.parent().find("input[type=submit]").attr('disabled','disabled'); } - $(".task-autocomplete").autocomplete({ - source: $(".task-autocomplete").data("search-url"), + input.autocomplete({ + source: input.data("search-url"), minLength: 1, select: function(event, ui) { - var field = $(".task-autocomplete").data("dst-field"); $("input[name=" + field + "]").val(ui.item.id); - $(".task-autocomplete").parent().find("input[type=submit]").removeAttr('disabled'); + if (extraField) { + $("input[name=" + extraField + "]").val(ui.item[extraField]); + } + + input.parent().find("input[type=submit]").removeAttr('disabled'); } }); - } + }); }; App.prototype.chosen = function() { diff --git a/assets/js/src/Project.js b/assets/js/src/Project.js new file mode 100644 index 00000000..e2412412 --- /dev/null +++ b/assets/js/src/Project.js @@ -0,0 +1,18 @@ +function Project() { +} + +Project.prototype.listen = function() { + $('.project-change-role').on('change', function() { + $.ajax({ + cache: false, + url: $(this).data('url'), + contentType: "application/json", + type: "POST", + processData: false, + data: JSON.stringify({ + "id": $(this).data('id'), + "role": $(this).val() + }) + }); + }); +}; |