From: Moritz Bunkus Date: Tue, 23 Apr 2013 08:30:06 +0000 (+0200) Subject: Pflichtenhefte auf Versionen zurücksetzen können X-Git-Tag: release-3.2.0beta~467^2~184 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=c96c4bb2c3561b54ef23330fdb1fa1d528b26fff;p=kivitendo-erp.git Pflichtenhefte auf Versionen zurücksetzen können --- diff --git a/SL/Controller/RequirementSpec.pm b/SL/Controller/RequirementSpec.pm index cac70a980..b557c036c 100644 --- a/SL/Controller/RequirementSpec.pm +++ b/SL/Controller/RequirementSpec.pm @@ -176,6 +176,23 @@ sub action_destroy { $self->redirect_to(action => 'list'); } +sub action_revert_to { + my ($self, %params) = @_; + + return $self->js->error(t8('Cannot revert a versioned copy.'))->render($self) if $self->requirement_spec->working_copy_id; + + my $versioned_copy = SL::DB::RequirementSpec->new(id => $::form->{versioned_copy_id})->load; + + $self->requirement_spec->delete_items; + $self->requirement_spec->copy_from( + $versioned_copy, + version_id => $versioned_copy->version_id, + ); + + flash_later('info', t8('The requirement spec has been reverted to version #1.', $self->requirement_spec->version->version_number)); + $self->js->redirect_to($self->url_for(action => 'show', id => $self->requirement_spec->id))->render($self); +} + # # filters # diff --git a/SL/DB/RequirementSpec.pm b/SL/DB/RequirementSpec.pm index 69a750bb0..6a43a2849 100644 --- a/SL/DB/RequirementSpec.pm +++ b/SL/DB/RequirementSpec.pm @@ -133,9 +133,34 @@ sub copy_from { $id_to_clone{ $item->id }->update_attributes(dependencies => [ map { $id_to_clone{$_->id} } @{ $item->dependencies } ]); } + $self->update_attributes(%attributes); + return $self; } +sub delete_items { + my ($self) = @_; + + my $worker = sub { + # First convert all items to sections so that deleting won't + # violate foreign key constraints on parent_id. + SL::DB::Manager::RequirementSpecItem->update_all( + set => { parent_id => undef, item_type => 'section' }, + where => [ + requirement_spec_id => $self->id, + '!parent_id' => undef, + ]); + + # Now delete all items in one go. + SL::DB::Manager::RequirementSpecItem->delete_all(where => [ requirement_spec_id => $self->id ]); + + # Last clear values in ourself. + $self->items([]); + }; + + return $self->db->in_transaction ? $worker->() : $self->db->do_transaction($worker); +} + sub previous_version { my ($self) = @_; diff --git a/js/locale/de.js b/js/locale/de.js index 704abd729..5bba34d11 100644 --- a/js/locale/de.js +++ b/js/locale/de.js @@ -7,13 +7,16 @@ namespace("kivi").setupLocale({ "Are you sure?":"Sind Sie sicher?", "Copy":"Kopieren", "Copy requirement spec":"Pflichtenheft kopieren", +"Create PDF":"PDF erzeugen", "Create new version":"Neue Version anlegen", "Database Connection Test":"Test der Datenbankverbindung", "Delete":"Löschen", "Delete requirement spec":"Pflichtenheft löschen", "Delete text block":"Textblock löschen", "Do you really want to cancel?":"Wollen Sie wirklich abbrechen?", +"Do you really want to revert to this version?":"Wollen Sie wirklich auf diese Version zurücksetzen?", "Do you want to set the account number \"#1\" to \"#2\" and the name \"#3\" to \"#4\"?":"Soll die Kontonummer \"#1\" zu \"#2\" und den Name \"#3\" zu \"#4\" geändert werden?", +"Edit":"Bearbeiten", "Edit text block":"Textblock bearbeiten", "Edit":"Bearbeiten", "Enter longdescription":"Langtext eingeben", @@ -21,6 +24,7 @@ namespace("kivi").setupLocale({ "Part picker":"Artikelauswahl", "Paste":"Einfügen", "Requirement spec actions:":"Pflichtenheftaktionen:", +"Revert to version":"Auf Version zurücksetzen", "Save":"Speichern", "The description is missing.":"Die Beschreibung fehlt.", "The name is missing.":"Der Name fehlt.", diff --git a/js/requirement_spec.js b/js/requirement_spec.js index 4ae545e4b..a03eb901b 100644 --- a/js/requirement_spec.js +++ b/js/requirement_spec.js @@ -252,7 +252,6 @@ function requirement_spec_text_block_popup_menu_hidden(opt) { return handle_text_block_popup_menu_markings(opt, false); } - function handle_item_popup_menu_markings(opt, add) { var id = find_item_id(opt.$trigger); if (id) @@ -323,6 +322,17 @@ function disable_requirement_spec_commands(key, opt) { // -------------------------------- versions ------------------------------- // ------------------------------------------------------------------------- +function find_versioned_copy_id(clicked_elt) { + var id = $(clicked_elt).find("[name=versioned_copy_id]"); + return id ? id.val() : undefined; +} + +function disable_versioned_copy_item_commands(key, opt) { + if (key === "revert_to_version") + return !find_versioned_copy_id(opt.$trigger); + return false; +} + function create_requirement_spec_version() { open_jqm_window({ url: 'controller.pl', data: { action: 'RequirementSpecVersion/new', @@ -331,6 +341,27 @@ function create_requirement_spec_version() { return true; } +function create_pdf_for_versioned_copy_ajax_call(key, opt) { + // TODO: create_pdf_for_versioned_copy_ajax_call + + return true; +} + +function revert_to_versioned_copy_ajax_call(key, opt) { + if (!confirm(kivi.t8('Do you really want to revert to this version?'))) + return true; + + var data = { + action: 'RequirementSpec/revert_to', + versioned_copy_id: find_versioned_copy_id(opt.$trigger), + id: $('#requirement_spec_id').val() + }; + + $.post("controller.pl", data, eval_json_result); + + return true; +} + // ------------------------------------------------------------------------- // ----------------------------- context menus ----------------------------- // ------------------------------------------------------------------------- @@ -414,16 +445,22 @@ function create_requirement_spec_context_menus() { $.contextMenu({ selector: '.time-cost-estimate-context-menu', - events: events, items: $.extend({ edit: { name: kivi.t8('Edit'), icon: "edit", callback: standard_time_cost_estimate_ajax_call } }, general_actions) }); $.contextMenu({ selector: '.edit-time-cost-estimate-context-menu', - events: events, items: $.extend({ save: { name: kivi.t8('Save'), icon: "save", callback: standard_time_cost_estimate_ajax_call } , cancel: { name: kivi.t8('Cancel'), icon: "close", callback: standard_time_cost_estimate_ajax_call } }, general_actions) }); + + $.contextMenu({ + selector: '.versioned-copy-context-menu', + items: $.extend({ + // create_pdf: { name: kivi.t8('Create PDF'), icon: "pdf", callback: create_pdf_for_versioned_copy_ajax_call } + revert_to_version: { name: kivi.t8('Revert to version'), icon: "revert", callback: revert_to_versioned_copy_ajax_call, disabled: disable_versioned_copy_item_commands } + }, general_actions) + }); } diff --git a/locale/de/all b/locale/de/all index 61c3d8e41..be833f06f 100755 --- a/locale/de/all +++ b/locale/de/all @@ -420,6 +420,7 @@ $self->{texts} = { 'Cannot post transaction!' => 'Rechnung kann nicht gebucht werden!', 'Cannot process payment for a closed period!' => 'Es kann keine Zahlung in einem abgeschlossenen Zeitraum verbucht werden!', 'Cannot remove files!' => 'Dateien können nicht gelöscht werden!', + 'Cannot revert a versioned copy.' => 'Eine versionierte Kopie selber kann nicht zurückgesetzt werden.', 'Cannot save account!' => 'Konto kann nicht gespeichert werden!', 'Cannot save order!' => 'Auftrag kann nicht gespeichert werden!', 'Cannot save preferences!' => 'Einstellungen können nicht gespeichert werden!', @@ -534,6 +535,7 @@ $self->{texts} = { 'Create Chart of Accounts' => 'Zu verwendender Kontenplan', 'Create Dataset' => 'Neue Datenbank anlegen', 'Create Date' => 'Erstelldatum', + 'Create PDF' => 'PDF erzeugen', 'Create a new acceptance status' => 'Einen neuen Abnahmestatus anlegen', 'Create a new background job' => 'Einen neuen Hintergrund-Job anlegen', 'Create a new business' => 'Einen neuen Kunden-/Lieferantentyp erfassen', @@ -785,6 +787,7 @@ $self->{texts} = { 'Do you really want to delete the selected links?' => 'Wollen Sie wirklich die ausgewählten Verknüpfungen löschen?', 'Do you really want to delete this object?' => 'Wollen Sie dieses Objekt wirklich löschen?', 'Do you really want to delete this warehouse?' => 'Wollen Sie dieses Lager wirklich löschen?', + 'Do you really want to revert to this version?' => 'Wollen Sie wirklich auf diese Version zurücksetzen?', 'Do you want to limit your search?' => 'Wollen Sie Ihre Suche spezialisieren?', 'Do you want to carry this shipping address over to the new purchase order so that the vendor can deliver the goods directly to your customer?' => 'Wollen Sie diese Lieferadresse in den neuen Lieferantenauftrag übernehmen, damit der Händler die Waren direkt an Ihren Kunden liefern kann?', 'Do you want to overwrite your current title?' => 'Wollen Sie den aktuellen Titel überschreiben?', @@ -1876,6 +1879,7 @@ $self->{texts} = { 'Revenue Account' => 'Erlöskonto', 'Revenues EU with UStId' => 'Erlöse EU m. UStId', 'Revenues EU without UStId' => 'Erlöse EU o. UStId', + 'Revert to version' => 'Auf Version zurücksetzen', 'Review of Aging list' => 'Altersstrukturliste', 'Right' => 'Rechts', 'Risk' => 'Risiko', @@ -2363,6 +2367,7 @@ $self->{texts} = { 'The required information consists of the IBAN, the BIC, the mandator ID and the mandate\'s date of signature.' => 'Die benötigten Informationen bestehen aus IBAN, BIC, Mandanten-ID und dem Unterschriftsdatum des Mandates.', 'The requirement spec has been created.' => 'Das Pflichtenheft wurde angelegt.', 'The requirement spec has been deleted.' => 'Das Pflichtenheft wurde gelöscht.', + 'The requirement spec has been reverted to version #1.' => 'Das Pflichtenheft wurde auf Version #1 zurückgesetzt.', 'The requirement spec has been saved.' => 'Das Pflichtenheft wurde gespeichert.', 'The requirement spec is in use and cannot be deleted.' => 'Das Pflichtenheft wird verwendet und kann nicht gelöscht werden.', 'The requirement spec status has been created.' => 'Der Pflichtenheftstatus wurde angelegt.', diff --git a/templates/webpages/requirement_spec_version/list.html b/templates/webpages/requirement_spec_version/list.html index 7c4f4d5ec..7f6ab52b9 100644 --- a/templates/webpages/requirement_spec_version/list.html +++ b/templates/webpages/requirement_spec_version/list.html @@ -1,9 +1,9 @@ [% USE HTML %][% USE L %][% USE LxERP %][%- USE P -%] - +
- + @@ -11,21 +11,21 @@ - - + + [%- IF SELF.requirement_spec.version_id %] + [% L.hidden_tag('versioned_copy_id', SELF.requirement_spec.version_id, no_id=1) %] + + [%- ELSE %] + + [%- END -%] [%- FOREACH versioned = SELF.versioned_copies %] - + + [% L.hidden_tag('versioned_copy_id', versioned.id, no_id=1) %]
[%- LxERP.t8("Version number") %]
[%- LxERP.t8("Version number") %]
[%- LxERP.t8("Description") %] [%- LxERP.t8("Internal comment") %] [%- LxERP.t8("Last modification") %]
- [%- IF SELF.requirement_spec.version_id %] - [%- LxERP.t8("Working copy identical to version number #1", SELF.requirement_spec.version.version_number) %] - [%- ELSE %] - [%- LxERP.t8("Working copy without version") %] - [%- END -%] -
[%- LxERP.t8("Working copy identical to version number #1", SELF.requirement_spec.version.version_number) %][%- LxERP.t8("Working copy without version") %][%- LxERP.t8("Working copy; no description yet") %]   [% SELF.requirement_spec.mtime.to_kivitendo(precision='minute') %]
[% HTML.escape(versioned.version.version_number) %] [% HTML.escape(P.truncate(versioned.description)) %] [% HTML.escape(P.truncate(versioned.comment)) %]