|
Lines 17-23
Link Here
|
| 17 |
message.text("Entity %s (code %s) for lang %s has correctly been updated with '%s'".format(data.entity, data.code, data.lang, data.translation)); |
17 |
message.text("Entity %s (code %s) for lang %s has correctly been updated with '%s'".format(data.entity, data.code, data.lang, data.translation)); |
| 18 |
} else if ( type == 'error_on_update' ) { |
18 |
} else if ( type == 'error_on_update' ) { |
| 19 |
message = $('<div class="dialog alert"></div>'); |
19 |
message = $('<div class="dialog alert"></div>'); |
| 20 |
message.text("An error occurred when updating this translation"); |
20 |
if ( data.error_code == 'already_exists' ) { |
|
|
21 |
message.text("This translation already exists for this language."); |
| 22 |
} else if ( data.error_code == 'no_change' ) { |
| 23 |
message.text("No change made for this translation."); |
| 24 |
} else { |
| 25 |
message.text("An error occurred when updating this translation."); |
| 26 |
} |
| 21 |
} else if ( type == 'success_on_delete' ) { |
27 |
} else if ( type == 'success_on_delete' ) { |
| 22 |
message = $('<div class="dialog message"></div>'); |
28 |
message = $('<div class="dialog message"></div>'); |
| 23 |
message.text("The translation (id %s) has been removed successfully".format(data.id)); |
29 |
message.text("The translation (id %s) has been removed successfully".format(data.id)); |
|
Lines 29-35
Link Here
|
| 29 |
message.text("Translation (id %s) has been added successfully".format(data.id)); |
35 |
message.text("Translation (id %s) has been added successfully".format(data.id)); |
| 30 |
} else if ( type == 'error_on_insert' ) { |
36 |
} else if ( type == 'error_on_insert' ) { |
| 31 |
message = $('<div class="dialog alert"></div>'); |
37 |
message = $('<div class="dialog alert"></div>'); |
| 32 |
message.text("An error occurred when adding this translation"); |
38 |
message = $('<div class="dialog alert"></div>'); |
|
|
39 |
if ( data.error_code == 'already_exists' ) { |
| 40 |
message.text("This translation already exists for this language."); |
| 41 |
} else { |
| 42 |
message.text("An error occurred when adding this translation"); |
| 43 |
} |
| 33 |
} |
44 |
} |
| 34 |
|
45 |
|
| 35 |
$(messages).append(message); |
46 |
$(messages).append(message); |
|
Lines 45-58
Link Here
|
| 45 |
type: 'PUT', |
56 |
type: 'PUT', |
| 46 |
url: '/cgi-bin/koha/svc/localization', |
57 |
url: '/cgi-bin/koha/svc/localization', |
| 47 |
success: function (data) { |
58 |
success: function (data) { |
| 48 |
if ( data.is_changed ) { |
59 |
if ( data.error ) { |
| 49 |
$(cell).css('background-color', '#00FF00'); |
60 |
$(cell).css('background-color', '#FF0000'); |
| 50 |
show_message({ type: 'success_on_update', data: data }); |
61 |
if ( $(cell).hasClass('lang') ) { |
| 51 |
} |
62 |
$(cell).text(data.lang) |
| 52 |
if ( $(cell).hasClass('lang') ) { |
63 |
} else if ( $(cell).hasClass('translation') ) { |
| 53 |
$(cell).text(data.lang) |
64 |
$(cell).text(data.translation) |
| 54 |
} else if ( $(cell).hasClass('translation') ) { |
65 |
} |
| 55 |
$(cell).text(data.translation) |
66 |
show_message({ type: 'error_on_update', data: data }); |
|
|
67 |
} else { |
| 68 |
if ( data.is_changed ) { |
| 69 |
$(cell).css('background-color', '#00FF00'); |
| 70 |
show_message({ type: 'success_on_update', data: data }); |
| 71 |
} else { |
| 72 |
$(cell).css('background-color', '#FF6400'); |
| 73 |
show_message({ type: 'error_on_update', data: { error_code: 'no_change' } }); |
| 74 |
} |
| 75 |
if ( $(cell).hasClass('lang') ) { |
| 76 |
$(cell).text(data.lang) |
| 77 |
} else if ( $(cell).hasClass('translation') ) { |
| 78 |
$(cell).text(data.translation) |
| 79 |
} |
| 56 |
} |
80 |
} |
| 57 |
}, |
81 |
}, |
| 58 |
error: function (data) { |
82 |
error: function (data) { |
|
Lines 149-157
Link Here
|
| 149 |
type: 'POST', |
173 |
type: 'POST', |
| 150 |
url: '/cgi-bin/koha/svc/localization', |
174 |
url: '/cgi-bin/koha/svc/localization', |
| 151 |
success: function (data) { |
175 |
success: function (data) { |
| 152 |
// FIXME Should append the delete link |
176 |
if ( data.error ) { |
| 153 |
table.row.add( [ data.id, data.entity, data.code, data.lang, data.translation, "" ] ).draw(); |
177 |
show_message({ type: 'error_on_insert', data: data }); |
| 154 |
show_message({ type: 'success_on_insert', data: data }); |
178 |
} else { |
|
|
179 |
// FIXME Should append the delete link |
| 180 |
table.row.add( [ data.id, data.entity, data.code, data.lang, data.translation, "" ] ).draw(); |
| 181 |
show_message({ type: 'success_on_insert', data: data }); |
| 182 |
} |
| 155 |
}, |
183 |
}, |
| 156 |
error: function (data) { |
184 |
error: function (data) { |
| 157 |
show_message({ type: 'error_on_insert', data: data }); |
185 |
show_message({ type: 'error_on_insert', data: data }); |