Implement set_value_action_for_date

This commit is contained in:
2018-08-09 18:28:13 +02:00
parent c35960f087
commit 1df55571b1
6 changed files with 59 additions and 2 deletions
@@ -1,5 +1,7 @@
import Ember from 'ember' import Ember from 'ember'
export default Ember.Controller.extend export default Ember.Controller.extend
set_value_on_non_final_till_date_date: moment()
set_value_on_non_final_till_date_action: null
operation_running_time: Ember.computed 'globals.operation_running', -> operation_running_time: Ember.computed 'globals.operation_running', ->
return '' unless start_time = @get('globals.operation_running') return '' unless start_time = @get('globals.operation_running')
duration = moment.duration(moment().diff(start_time)) duration = moment.duration(moment().diff(start_time))
@@ -10,3 +12,9 @@ export default Ember.Controller.extend
minutes = ('0' + duration.minutes()).slice(-2) minutes = ('0' + duration.minutes()).slice(-2)
seconds = ('0' + duration.seconds()).slice(-2) seconds = ('0' + duration.seconds()).slice(-2)
"#{hours}:#{minutes}:#{seconds}" "#{hours}:#{minutes}:#{seconds}"
actions:
set_value_on_non_final_till_date: ->
return unless date = @get('set_value_on_non_final_till_date_date')
return unless action = @get('set_value_on_non_final_till_date_action')
@set 'globals.operation_running', moment()
action.set_value_on_non_final_till_date(date: date.format('YYYY-MM-DD'), event_value: 't')
+19 -1
View File
@@ -2,6 +2,8 @@
import Ember from 'ember'; import Ember from 'ember';
export default Ember.Controller.extend({ export default Ember.Controller.extend({
set_value_on_non_final_till_date_date: moment(),
set_value_on_non_final_till_date_action: null,
operation_running_time: Ember.computed('globals.operation_running', function() { operation_running_time: Ember.computed('globals.operation_running', function() {
var duration, hours, minutes, seconds, start_time; var duration, hours, minutes, seconds, start_time;
if (!(start_time = this.get('globals.operation_running'))) { if (!(start_time = this.get('globals.operation_running'))) {
@@ -16,5 +18,21 @@ export default Ember.Controller.extend({
seconds = ('0' + duration.seconds()).slice(-2); seconds = ('0' + duration.seconds()).slice(-2);
return hours + ":" + minutes + ":" + seconds; return hours + ":" + minutes + ":" + seconds;
} }
}) }),
actions: {
set_value_on_non_final_till_date: function() {
var action, date;
if (!(date = this.get('set_value_on_non_final_till_date_date'))) {
return;
}
if (!(action = this.get('set_value_on_non_final_till_date_action'))) {
return;
}
this.set('globals.operation_running', moment());
return action.set_value_on_non_final_till_date({
date: date.format('YYYY-MM-DD'),
event_value: 't'
});
}
}
}); });
@@ -1,5 +1,6 @@
import Ember from 'ember' import Ember from 'ember'
import DS from 'ember-data' import DS from 'ember-data'
import { modelAction } from 'ember-custom-actions'
import add_business_day_computations from 'ember-panda/utils/business-day-computations' import add_business_day_computations from 'ember-panda/utils/business-day-computations'
export value_type_options = ['boolean', 'date', 'number', 'select', 'string', 'text', 'timestamp'] export value_type_options = ['boolean', 'date', 'number', 'select', 'string', 'text', 'timestamp']
@@ -40,6 +41,8 @@ Model =
absolute_position: Ember.computed 'workflow_group.position', 'position', -> absolute_position: Ember.computed 'workflow_group.position', 'position', ->
(@get('workflow_group.position') || 99) * 100 + (@get('position') || 99 ) (@get('workflow_group.position') || 99) * 100 + (@get('position') || 99 )
set_value_on_non_final_till_date: modelAction('set_value_on_non_final_till_date', pushToStore: false)
#drag_identifier: Ember.computed 'id', 'workflow_group.id', 'position', -> #drag_identifier: Ember.computed 'id', 'workflow_group.id', 'position', ->
# "#{@get('id')}-#{@get('workflow_group.id')}-#{@get('position')}" # "#{@get('id')}-#{@get('workflow_group.id')}-#{@get('position')}"
#smart_position: Ember.computed 'done', 'position', -> #smart_position: Ember.computed 'done', 'position', ->
@@ -5,6 +5,10 @@ import Ember from 'ember';
import DS from 'ember-data'; import DS from 'ember-data';
import {
modelAction
} from 'ember-custom-actions';
import add_business_day_computations from 'ember-panda/utils/business-day-computations'; import add_business_day_computations from 'ember-panda/utils/business-day-computations';
export var value_type_options = ['boolean', 'date', 'number', 'select', 'string', 'text', 'timestamp']; export var value_type_options = ['boolean', 'date', 'number', 'select', 'string', 'text', 'timestamp'];
@@ -77,6 +81,9 @@ Model = {
}), }),
absolute_position: Ember.computed('workflow_group.position', 'position', function() { absolute_position: Ember.computed('workflow_group.position', 'position', function() {
return (this.get('workflow_group.position') || 99) * 100 + (this.get('position') || 99); return (this.get('workflow_group.position') || 99) * 100 + (this.get('position') || 99);
}),
set_value_on_non_final_till_date: modelAction('set_value_on_non_final_till_date', {
pushToStore: false
}) })
}; };
+19
View File
@@ -20,3 +20,22 @@ if globals.operation_running
else else
.ui.horizontal.divider= t 'project.operate.set_value_on_non_final_with_closed_group.title' .ui.horizontal.divider= t 'project.operate.set_value_on_non_final_with_closed_group.title'
.ui.segment .ui.segment
.ui.horizontal.divider= t 'project.operate.set_value_on_non_final_till_date.title'
.ui.segment
= ui-dropdown class='search selection' selected=set_value_on_non_final_till_date_action onChange=(action (mut set_value_on_non_final_till_date_action)) fullTextSearch=true as |execute mapper|
.default.text= t 'action.select_model' modelPath='models.workflow_action_definition'
i.dropdown.icon
.menu
.item data-value='{{map-value mapper null}}' --
each model.sorted_workflow_action_definitions as |workflow_action_definition|
.item data-value='{{map-value mapper workflow_action_definition}}'
= workflow_action_definition.title
.ui.small.icon.input= ui-calendar-moment type='date' momentValue=(readonly set_value_on_non_final_till_date_date) onChange=(action (mut set_value_on_non_final_till_date_date)) placeholder='X'
if set_value_on_non_final_till_date_action
'
span.between-brackets= set_value_on_non_final_till_date_action.identifier
'
if (eq set_value_on_non_final_till_date_action.value_type 'boolean')
button.ui.secondary.button click="set_value_on_non_final_till_date" Boom!
else
span.ui.yellow.basic.label Non boolean not yet supported
@@ -37,5 +37,7 @@ translations = project:
title: '${models.project} operations' title: '${models.project} operations'
operation_running_text: 'There already is an operation running' operation_running_text: 'There already is an operation running'
set_value_on_non_final_with_closed_group: set_value_on_non_final_with_closed_group:
title: 'Set value on actions where group is closed' title: 'Set value on non final actions where group is closed'
set_value_on_non_final_till_date:
title: 'Set value on non final actions till date'
export default translations export default translations