app/assets/javascripts/fiona7_ui.js in infopark_fiona7-1.1.0.0.10 vs app/assets/javascripts/fiona7_ui.js in infopark_fiona7-1.2.0.0.0

- old
+ new

@@ -102,10 +102,17 @@ 'commands.release_obj.dialog.description': 'Eine Arbeitsversion zu veröffentlichen ist endgültig. Dieser Vorgang kann nicht rückgängig gemacht werden.', 'commands.release_obj.dialog.placeholder': 'Bitte Kommentar eintragen', 'commands.release_obj.dialog.confirm': 'Freigeben', 'commands.release_obj.failed': 'Freigabe fehlgeschlagen', + 'commands.edit_obj.title': 'Seite bearbeiten', + 'commands.edit_obj.dialog.title': 'Seite bearbeiten?', + 'commands.edit_obj.dialog.description': 'Es wird eine neue Arbeitsversion erstellt.', + 'commands.edit_obj.dialog.placeholder': 'Bitte Kommentar eintragen', + 'commands.edit_obj.dialog.confirm': 'Bearbeiten', + 'commands.edit_obj.failed': 'Bearbeitung fehlgeschlagen', + 'commands.forward_obj.title': 'Seite weiterleiten', 'commands.forward_obj.dialog.title': 'Seite weiterleiten?', 'commands.forward_obj.dialog.description': 'Die Arbeitsversion wird an einen weiteren Bearbeiter weitergeleitet. Dieser Vorgang kann nicht rückgängig gemacht werden.', 'commands.forward_obj.dialog.placeholder': 'Bitte Kommentar eintragen', 'commands.forward_obj.dialog.confirm': 'Weiterleiten', @@ -135,11 +142,14 @@ 'commands.take_obj.title': 'Seite übernehmen', 'commands.take_obj.dialog.title': 'Seite übernehmen?', 'commands.take_obj.dialog.description': 'Die Arbeitsversion wird übernommen. Dieser Vorgang kann nicht rückgängig gemacht werden.', 'commands.take_obj.dialog.placeholder': 'Bitte Kommentar eintragen', 'commands.take_obj.dialog.confirm': 'Übernehmen', - 'commands.take_obj.failed': 'Übernahme fehlgeschlagen' + 'commands.take_obj.failed': 'Übernahme fehlgeschlagen', + + 'editing_disabled.workflow': 'Die Datei unterliegt einem Workflow und kann nicht direkt bearbeitet werden.', + 'editing_disabled.permissions': 'Ihnen fehlen die Rechte um die Datei zu bearbeiten' }, 'de'); $.i18n().load({ 'commands.release_obj.title': 'Release page', 'commands.release_obj.not_modified_obj': 'This resource has not been modified. Therefore, nothing can be released.', @@ -147,27 +157,34 @@ 'commands.release_obj.dialog.description': 'Releasing an edited page is final. This operation cannot be reverted.', 'commands.release_obj.dialog.placeholder': 'Comment', 'commands.release_obj.dialog.confirm': 'Release', 'commands.release_obj.failed': 'Release failed', + 'commands.edit_obj.title': 'Edit page', + 'commands.edit_obj.dialog.title': 'Edit this page?', + 'commands.edit_obj.dialog.description': 'A new version of this page will be created.', + 'commands.edit_obj.dialog.placeholder': 'Comment', + 'commands.edit_obj.dialog.confirm': 'Edit', + 'commands.edit_obj.failed': 'Edit failed', + 'commands.forward_obj.title': 'Forward page', 'commands.forward_obj.dialog.title': 'Forward this page?', 'commands.forward_obj.dialog.description': 'Forward and edited page is final. This operation cannot be reverted.', 'commands.forward_obj.dialog.placeholder': 'Comment', 'commands.forward_obj.dialog.confirm': 'Forward', 'commands.forward_obj.failed': 'Forward failed', 'commands.reject_obj.title': 'Reject page', 'commands.reject_obj.dialog.title': 'Reject this page?', - 'commands.reject_obj.dialog.description': 'Die Arbeitsversion wird abgelehnt. Dieser Vorgang kann nicht rückgängig gemacht werden.', + 'commands.reject_obj.dialog.description': 'Current page will be rejected. This operation cannot be reverted.', 'commands.reject_obj.dialog.placeholder': 'Comment', 'commands.reject_obj.dialog.confirm': 'Reject', 'commands.reject_obj.failed': 'Reject failed', 'commands.sign_obj.title': 'Sign page', 'commands.sign_obj.dialog.title': 'Sign this page?', - 'commands.sign_obj.dialog.description': 'Die eingereichte Version wird abgezeichnet. Dieser Vorgang kann nicht rückgängig gemacht werden.', + 'commands.sign_obj.dialog.description': 'Committed page will be signed. This operation cannot be reverted.', 'commands.sign_obj.dialog.placeholder': 'Comment', 'commands.sign_obj.dialog.confirm': 'Sign', 'commands.sign_obj.failed': 'Signing failed', 'commands.commit_obj.title': 'Commit page', @@ -180,91 +197,120 @@ 'commands.take_obj.title': 'Take page', 'commands.take_obj.dialog.title': 'Tage this page?', 'commands.take_obj.dialog.description': 'Die Arbeitsversion wird übernommen. Dieser Vorgang kann nicht rückgängig gemacht werden.', 'commands.take_obj.dialog.placeholder': 'Comment', 'commands.take_obj.dialog.confirm': 'Take', - 'commands.take_obj.failed': 'Take failed' + 'commands.take_obj.failed': 'Take failed', + + 'editing_disabled.workflow': 'The current page belongs to a workflow and cannot be edited directly.', + 'editing_disabled.permissions': 'You do not have the permissions required to edit this page.' }, 'en'); var dialog_icons = { + "edit": "", "forward": "", "reject": "", - "commit": "&#xcheck;", + "commit": "", "sign": "", "take": "", "release": "" }; var icons = { + "edit": "pen", "forward": "check", "reject": "cross", "commit": "check", "sign": "circ_pen", "take": "exclamation", "release": "globe" }; - var actions = ["forward", "reject","commit", "sign", "take", "release"]; - actions = ["release"]; + var actions = ["edit", "forward", "reject","commit", "sign", "take"]; scrivito.gui.on('document', function(cms_document) { - //console.log('adding release button'); - var obj = cms_document.page(); + var page_config = (cms_document.page_config() || {})['current_page'] || {}; + var obj = cms_document.page(); + var buttons = page_config['buttons'] || []; + var workflow_enabled = page_config['workflow']; - _.each(actions, function(action,idx) { + if (cms_document.browser_window().name !== 'scrivito_application') { + // TODO: add special handling for scrivito_details_dialog and scrivito_inspector + return; + } + + /* release button */ + scrivito.page_menu(cms_document).add('fiona7.idx'+99+'.release_obj', { + title: scrivito.t('commands.release_obj.title'), + icon: icons['release'], + + present: function() { + return scrivito.editing_context.selected_workspace.is_editable() && obj && (!workflow_enabled || (buttons.indexOf('release') !== -1)); + }, + + disabled: function() { + if (!obj.modification()) { + return scrivito.t('commands.release_obj.not_modified_obj'); + } + if (obj.has_restriction()) { + return obj.restriction_messages().join("; "); + } + }, + + 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(); + })); + }); + } + }); + /* TODO: enforce permissions */ + + /* TODO: better sorting */ + + /* disable editing */ + setTimeout(function (){ + if (page_config['editing_disabled']) { + scrivito.editing_mode.disable(scrivito.t('editing_disabled.workflow')); + } else { + scrivito.editing_mode.enable(); + } + }, 0); + + /* add workflow buttons */ + $.each(actions, function(idx, action) { scrivito.page_menu(cms_document).add('fiona7.idx'+idx+'.'+action+'_obj', { title: scrivito.t('commands.'+action+'_obj.title'), icon: icons[action], present: function() { - return scrivito.editing_context.selected_workspace.is_editable() && obj;// && !obj.is_deleted() && scrivito.user_permissions.can(action + '_obj'); + return buttons.indexOf(action) !== -1; }, - disabled: function() { - if (action == 'release' && !obj.modification()) { - return scrivito.t('commands.release_obj.not_modified_obj'); - } - if (action == 'release' && obj.has_restriction()) { - return obj.restriction_messages().join("; "); - - } - }, - - 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(); + open_confirmation_dialog(action, dialog_icons[action]).done(function(comment) { + scrivito.with_saving_overlay(scrivito.ajax('PUT', 'objs/workflow/'+action, {data: {id: obj.id(), comment: comment}}).then(function() { + if (action == 'edit' || action == 'take') { + + if (!scrivito.editing_context.is_editing_mode()) { + return scrivito.with_saving_overlay( + scrivito.change_editing_context({display_mode: 'editing', workspace_id: 'rtc'})); + } else { + return scrivito.with_saving_overlay(scrivito.reload()); + } + } else { + return scrivito.with_saving_overlay(scrivito.reload()); + } })); }); } }); }); - - //var menu = cms_document.menu(); - //menu.push(scrivito.command_separator.create_instance({id: 'fiona7.zz_sparator'})); - //cms_document.set_menu(menu); - - //scrivito.configure_menu_order(['fiona7.*', '*']); }); return; - - /* enforce permissions */ - var originalGuiStart = scrivito.gui.start; - scrivito.gui.start = function () { - originalGuiStart.call(this, arguments); - if (scrivito.in_editable_view()) { - if (!scrivito.user_permissions.can('write_obj')) { - $('.switch_to_view_mode').click(); - } - } else { - if (!scrivito.user_permissions.can('write_obj')) { - $('.scrivito_viewmode_editing').remove(); - } - } - }; - }());