+// -------------------------------------------------------------------------
+// -------------------------- time/cost estimate ---------------------------
+// -------------------------------------------------------------------------
+
+ns.standard_time_cost_estimate_ajax_call = function(key, opt) {
+ if (key == 'cancel') {
+ if (confirm(kivi.t8('Do you really want to cancel?'))) {
+ $('#time_cost_estimate').show();
+ $('#time_cost_estimate_form_container').remove();
+ }
+ return true;
+ }
+
+ var add_data = '';
+ if (key == 'save_keep_open') {
+ key = 'save';
+ add_data = 'keep_open=1&';
+ }
+
+ var data = "action=RequirementSpec/ajax_" + key + "_time_and_cost_estimate&" + add_data;
+
+ if (key == 'save')
+ data += $('#edit_time_cost_estimate_form').serialize()
+ + '&' + $('#current_content_type').serialize()
+ + '&' + $('#current_content_id').serialize();
+ else
+ data += 'id=' + encodeURIComponent($('#requirement_spec_id').val());
+
+ $.post("controller.pl", data, kivi.eval_json_result);
+
+ return true;
+};
+
+ns.time_cost_estimate_input_key_down = function(event) {
+ if(event.keyCode == 13) {
+ event.preventDefault();
+ ns.standard_time_cost_estimate_ajax_call('save');
+ return false;
+ }
+};
+
+// -------------------------------------------------------------------------
+// -------------------------- additional parts -----------------------------
+// -------------------------------------------------------------------------
+
+ns.standard_additional_parts_ajax_call = function(key, opt) {
+ var add_data = '';
+ if (key == 'save_keep_open') {
+ key = 'save';
+ add_data = 'keep_open=1&';
+ }
+
+ var data = "action=RequirementSpecPart/ajax_" + key + "&" + add_data + 'requirement_spec_id=' + encodeURIComponent($('#requirement_spec_id').val()) + '&';
+
+ if (key == 'save')
+ data += $('#edit_additional_parts_form').serialize();
+
+ $.post("controller.pl", data, kivi.eval_json_result);
+
+ return true;
+};
+
+ns.prepare_edit_additional_parts_form = function() {
+ $("#edit_additional_parts_list tbody").sortable({
+ distance: 5,
+ handle: '.dragdrop',
+ helper: function(event, ui) {
+ ui.children().each(function() {
+ $(this).width($(this).width());
+ });
+ return ui;
+ }
+
+ });
+};
+
+ns.cancel_edit_additional_parts_form = function() {
+ if (confirm(kivi.t8('Do you really want to cancel?'))) {
+ $('#additional_parts_list_container').show();
+ $('#additional_parts_form_container').remove();
+ }
+ return true;
+};
+
+ns.additional_parts_input_key_down = function(event) {
+ if(event.keyCode == 13) {
+ event.preventDefault();
+ ns.standard_additional_parts_ajax_call('save');
+ return false;
+ }
+};
+
+ns.add_additional_part = function() {
+ var part_id = $('#additional_parts_add_part_id').val();
+ if (!part_id || (part_id == ''))
+ return false;
+
+ var rspec_id = $('#requirement_spec_id').val();
+ var data = 'action=RequirementSpecPart/ajax_add&requirement_spec_id=' + encodeURIComponent(rspec_id) + '&part_id=' + encodeURIComponent(part_id);
+
+ $.post("controller.pl", data, kivi.eval_json_result);
+
+ return true;
+};
+
+ns.delete_additional_part = function(key, opt) {
+ opt.$trigger.remove();
+ if (!$('#edit_additional_parts_list tbody tr').size()) {
+ $('#edit_additional_parts_list_empty').show();
+ $('#edit_additional_parts_list').hide();
+ }
+
+ return true;
+};
+