|
1 | 1 | {% extends "base_lv1.html" %}
|
2 | 2 | {% load i18n %}
|
3 | 3 | {% load inctag_toolbars %}
|
| 4 | +{% load static %} |
4 | 5 |
|
5 | 6 | {% block page_title %}{% trans "Journal Editorial Board" %}{% endblock %}
|
| 7 | + |
6 | 8 | {% block content %}
|
7 | 9 |
|
8 | 10 | {% if request.user.get_profile.is_editor %}
|
|
19 | 21 | {% endblock %}
|
20 | 22 | {% block extrafooter %}
|
21 | 23 | {{ block.super }}
|
| 24 | + |
22 | 25 | <script>
|
23 |
| - $(function() { |
24 |
| - |
25 |
| - function display_error(message){ |
26 |
| - var template = '<div class="sys-msgs">' + |
27 |
| - '<div class="sys-msgs-wrapper">' + |
28 |
| - '<div class="alert alert-error">'+ |
29 |
| - '<i class="icon-exclamation-sign"></i> ' + message + |
30 |
| - '<button class="close" data-dismiss="alert" type="button">×</button>' + |
31 |
| - '</div>' + |
32 |
| - '</div>'+ |
33 |
| - '</div>'; |
34 |
| - $('div.mainContent').prepend(template).show(); |
| 26 | + |
| 27 | + //Register autocomplete when model made visible to the user |
| 28 | + $('#id_modal_form').on('loaded', function(){ |
| 29 | + |
| 30 | + $('#id_institution').devbridgeAutocomplete({ |
| 31 | + serviceUrl: "{{SETTINGS.WAYTA_URL}}{{SETTINGS.WAYTA_PATH}}institution", |
| 32 | + dataType: 'jsonp', |
| 33 | + paramName: 'q', |
| 34 | + noCache: true, |
| 35 | + params: {'accuracy': 3}, |
| 36 | + minChars: 3, |
| 37 | + transformResult: function(response) { |
| 38 | + return { |
| 39 | + query:'q', |
| 40 | + suggestions: $.map(response.choices, function(dataItem) { |
| 41 | + return { value: dataItem.value, data: |
| 42 | + {'country': dataItem.country, |
| 43 | + 'city': dataItem.city, |
| 44 | + 'state': dataItem.state, |
| 45 | + 'iso3166': dataItem.iso3166 }}; |
| 46 | + }) |
| 47 | + } |
| 48 | + }, |
| 49 | + |
| 50 | + formatResult: function (suggestion, currentValue) { |
| 51 | + return '<b>{% trans 'Institution' %}:</b> ' + suggestion.value + '</br>' + |
| 52 | + '<b>{% trans 'City' %}:</b> ' + suggestion.data.city + '</br>' + |
| 53 | + '<b>{% trans 'State' %}:</b> ' + suggestion.data.state + '</br>' + |
| 54 | + '<b>{% trans 'Country' %}:</b> ' + suggestion.data.country; |
| 55 | + }, |
| 56 | + |
| 57 | + onSelect: function (suggestion) { |
| 58 | + $('#id_city').val(suggestion.data.city) |
| 59 | + $('#id_state').val(suggestion.data.state) |
| 60 | + |
| 61 | + $('#id_country option').each(function() { |
| 62 | + if (this.value == suggestion.data.iso3166){ |
| 63 | + this.selected = this.text; |
| 64 | + $(".chzn-select").trigger("chosen:updated"); |
| 65 | + } |
| 66 | + }); |
| 67 | + }, |
| 68 | + |
| 69 | + appendTo: $('#selection') |
| 70 | + |
| 71 | + });//devbridgeAutocomplete |
| 72 | + |
| 73 | + });//shown |
| 74 | + |
| 75 | + function display_error(message){ |
| 76 | + var template = '<div class="sys-msgs">' + |
| 77 | + '<div class="sys-msgs-wrapper">' + |
| 78 | + '<div class="alert alert-error">'+ |
| 79 | + '<i class="icon-exclamation-sign"></i> ' + message + |
| 80 | + '<button class="close" data-dismiss="alert" type="button">×</button>' + |
| 81 | + '</div>' + |
| 82 | + '</div>'+ |
| 83 | + '</div>'; |
| 84 | + $('div.mainContent').prepend(template).show(); |
| 85 | + } |
| 86 | + |
| 87 | + $('form.form_move_role').submit(function(event) { |
| 88 | + |
| 89 | + {# basic validation before submittion #} |
| 90 | + var form = $(this); |
| 91 | + var f_issue_pk = form.find('.issue_pk').val(); |
| 92 | + var f_board_pk = form.find('.board_pk').val(); |
| 93 | + var f_role_name = form.find('.role_name').val(); |
| 94 | + var f_role_position = form.find('.role_position').val(); |
| 95 | + var f_direction = form.find('.direction').val(); |
| 96 | + |
| 97 | + var validation_results = { |
| 98 | + has_error: false, |
| 99 | + error_msg: "" {# this message is only for debug, not displayed to user #} |
35 | 100 | }
|
36 | 101 |
|
37 |
| - $('form.form_move_role').submit(function(event) { |
38 |
| - {# basic validation before submittion #} |
39 |
| - var form = $(this); |
40 |
| - var f_issue_pk = form.find('.issue_pk').val(); |
41 |
| - var f_board_pk = form.find('.board_pk').val(); |
42 |
| - var f_role_name = form.find('.role_name').val(); |
43 |
| - var f_role_position = form.find('.role_position').val(); |
44 |
| - var f_direction = form.find('.direction').val(); |
45 |
| - |
46 |
| - var validation_results = { |
47 |
| - has_error: false, |
48 |
| - error_msg: "" {# this message is only for debug, not displayed to user #} |
| 102 | + if ($.trim(f_issue_pk) === "") { |
| 103 | + validation_results = { |
| 104 | + has_error: true, |
| 105 | + error_msg: "issue_pk field is empty" |
49 | 106 | }
|
| 107 | + } |
50 | 108 |
|
51 |
| - if ($.trim(f_issue_pk) === "") { |
52 |
| - validation_results = { |
53 |
| - has_error: true, |
54 |
| - error_msg: "issue_pk field is empty" |
55 |
| - } |
| 109 | + if ($.trim(f_board_pk) === "") { |
| 110 | + validation_results = { |
| 111 | + has_error: true, |
| 112 | + error_msg: "board_pk field is empty" |
56 | 113 | }
|
| 114 | + } |
57 | 115 |
|
58 |
| - if ($.trim(f_board_pk) === "") { |
59 |
| - validation_results = { |
60 |
| - has_error: true, |
61 |
| - error_msg: "board_pk field is empty" |
62 |
| - } |
| 116 | + if ($.trim(f_role_name) === "") { |
| 117 | + validation_results = { |
| 118 | + has_error: true, |
| 119 | + error_msg: "role_name field is empty" |
63 | 120 | }
|
| 121 | + } |
64 | 122 |
|
65 |
| - if ($.trim(f_role_name) === "") { |
66 |
| - validation_results = { |
67 |
| - has_error: true, |
68 |
| - error_msg: "role_name field is empty" |
69 |
| - } |
| 123 | + if ($.trim(f_role_position) === "") { |
| 124 | + validation_results = { |
| 125 | + has_error: true, |
| 126 | + error_msg: "role_position field is empty" |
70 | 127 | }
|
| 128 | + } |
71 | 129 |
|
72 |
| - if ($.trim(f_role_position) === "") { |
73 |
| - validation_results = { |
74 |
| - has_error: true, |
75 |
| - error_msg: "role_position field is empty" |
76 |
| - } |
| 130 | + if ($.trim(f_direction) === "") { |
| 131 | + validation_results = { |
| 132 | + has_error: true, |
| 133 | + error_msg: "direction field is empty" |
77 | 134 | }
|
| 135 | + } |
78 | 136 |
|
79 |
| - if ($.trim(f_direction) === "") { |
80 |
| - validation_results = { |
81 |
| - has_error: true, |
82 |
| - error_msg: "direction field is empty" |
83 |
| - } |
84 |
| - } |
85 |
| - if (validation_results.has_error) { |
| 137 | + if (validation_results.has_error) { |
86 | 138 | display_error("{% trans 'Can not move this block, please try again later' %}");
|
87 |
| - console.log("validation errors when submit form", form, validation_results); |
88 | 139 | return false;
|
89 | 140 | }
|
| 141 | + |
90 | 142 | });
|
91 | 143 |
|
92 |
| - $('.btn-move-role').click(function(event) { |
93 |
| - event.preventDefault(); |
94 |
| - var $this = $(this); |
| 144 | + $('.btn-move-role').click(function(event) { |
| 145 | + event.preventDefault(); |
| 146 | + var $this = $(this); |
95 | 147 |
|
96 |
| - if ($this.hasClass('disabled')) { |
97 |
| - return; {# disabled buttons must be ignored #} |
98 |
| - } |
| 148 | + if ($this.hasClass('disabled')) { |
| 149 | + return; {# disabled buttons must be ignored #} |
| 150 | + } |
99 | 151 |
|
100 |
| - {# update 'direction' field, depending on which btn clicked: up or down #} |
101 |
| - var direction = $this.data('direction'); |
102 |
| - var form = $this.parents('.form_move_role'); |
103 |
| - form.find('.direction').val(direction); |
104 |
| - form.submit(); |
| 152 | + {# update 'direction' field, depending on which btn clicked: up or down #} |
| 153 | + var direction = $this.data('direction'); |
| 154 | + var form = $this.parents('.form_move_role'); |
| 155 | + form.find('.direction').val(direction); |
| 156 | + form.submit(); |
105 | 157 |
|
106 |
| - }); |
107 | 158 | });
|
| 159 | + |
108 | 160 | </script>
|
109 | 161 | {% endblock %}
|
0 commit comments