app/assets/javascripts/fiona7_ui.js in infopark_fiona7-0.71.1.12 vs app/assets/javascripts/fiona7_ui.js in infopark_fiona7-1.1.0.0.0

- old
+ new

@@ -36,10 +36,67 @@ accept_button_text: scrivito.t('commands.'+action+'_obj.dialog.confirm'), accept_button_color: 'green' }); }; + var open_release_dialog = function(obj_id) { + var base_url = window.location.protocol + '//' + window.location.host + '/__scrivito/'; + var path = 'objs/' + obj_id + '/release/preview'; + + var deferred = $.Deferred(); + + $.ajax(base_url + path, { + type: 'GET', + dataType: 'html', + cache: false + }).then( + function(result, text_status, xhr) { + var view = $(result); + + $('#scrivito_editing').append(view); + + var accept = function() { + scrivito.dialog.close_with_transition(view); + + var checkedObjs = view.find(':checked').map(function() { + return $(this).val(); + }).get(); + + var comment = view.find('#release-comment').val(); + + deferred.resolve(checkedObjs, comment); + return false; + }; + + var cancel = function() { + scrivito.dialog.close_with_transition(view); + deferred.reject(); + return false; + }; + + var expand = function() { + $(this).next().slideToggle(); + return false; + }; + + view.find('.scrivito_accept').on('click', accept); + view.find('.scrivito_cancel').on('click', cancel); + + view.find('.expanding').on('click', expand); + + scrivito.dialog.open_and_center_with_transition(view).then(function() { + // view loaded + }); + + scrivito.with_dialog_behaviour(view, deferred, {enter: accept, escape: cancel}); + }, + function(xhr, text_status, error) { + }); + + return deferred; + }; + $.i18n().load({ 'commands.release_obj.title': 'Seite freigeben', 'commands.release_obj.not_modified_obj': 'Diese Seite wurde nicht geändert. Daher gibt es nichts zu freigeben.', 'commands.release_obj.dialog.title': 'Änderungen an dieser Seite veröffentlichen?', 'commands.release_obj.dialog.description': 'Eine Arbeitsversion zu veröffentlichen ist endgültig. Dieser Vorgang kann nicht rückgängig gemacht werden.', @@ -174,9 +231,19 @@ update: function() { return obj.reload(); }, execute: function() { + open_release_dialog(obj.id()).done(function(objIds, comment) { + scrivito.with_saving_overlay(scrivito.ajax('PUT', 'objs/release', {data: {objs: objIds, comment: comment}}).then(function() { + scrivito.reload(); + }).fail(function(error) { + scrivito.alert_dialog(scrivito.t('commands.'+action+'_obj.failed')); + })); + }); + + return; + /* TODO: implement permission check */ open_confirmation_dialog(action, dialog_icons[action]).done(function(comment) { scrivito.with_saving_overlay(scrivito.ajax('PUT', 'objs/' + obj.id() + '/release?comment=' + (comment || "")).then(function() { scrivito.reload(); }).fail(function(error) {