task-manager 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. data/app/assets/javascripts/task-manager/extjs/app/controller/Plans.js +19 -0
  2. data/app/assets/javascripts/task-manager/extjs/app/controller/Tasks.js +1 -1
  3. data/app/assets/javascripts/task-manager/extjs/app/helper/ApplicationHelper.js +1 -1
  4. data/app/assets/javascripts/task-manager/extjs/app/model/Task.js +3 -2
  5. data/app/assets/javascripts/task-manager/extjs/app/store/Assignees.js +1 -1
  6. data/app/assets/javascripts/task-manager/extjs/app/store/Months.js +2 -2
  7. data/app/assets/javascripts/task-manager/extjs/app/view/assignee/TreeCombo.js +8 -6
  8. data/app/assets/javascripts/task-manager/extjs/app/view/plan/Form.js +27 -4
  9. data/app/assets/javascripts/task-manager/extjs/app/view/plan/Grid.js +3 -3
  10. data/app/assets/javascripts/task-manager/extjs/app/view/plan/Index.js +1 -1
  11. data/app/assets/javascripts/task-manager/extjs/app/view/plan/Search.js +2 -2
  12. data/app/assets/javascripts/task-manager/extjs/app/view/task/Grid.js +2 -2
  13. data/app/assets/javascripts/task-manager/extjs/app/view/task/Index.js +1 -1
  14. data/app/assets/javascripts/task-manager/extjs/app/view/task/Search.js +1 -1
  15. data/app/assets/javascripts/task-manager/extjs/lib/ux/CheckboxListCombo.js +1 -1
  16. data/app/assets/javascripts/task-manager/extjs/lib/ux/TreeCombo.js +1 -0
  17. data/app/controllers/task_manager/api/v1/plans_controller.rb +1 -1
  18. data/app/controllers/task_manager/api/v1/tasks_controller.rb +2 -2
  19. data/app/models/task_manager/plan.rb +3 -7
  20. data/app/models/task_manager/task.rb +6 -1
  21. data/db/migrate/20121105170602_create_task_manager_tasks.rb +1 -0
  22. data/lib/task-manager.rb +4 -0
  23. data/lib/task-manager/version.rb +1 -1
  24. metadata +4 -4
@@ -22,6 +22,9 @@ Ext.define('TM.controller.Plans', {
22
22
  }, {
23
23
  ref: 'planGrid',
24
24
  selector: 'plan_grid'
25
+ }, {
26
+ ref: 'callbackCheckboxCombo',
27
+ selector: 'plan_form callback_checkboxcombo'
25
28
  }],
26
29
 
27
30
  index: function() {
@@ -53,10 +56,22 @@ Ext.define('TM.controller.Plans', {
53
56
  },
54
57
  'plan_form button[action="cancel"]': {
55
58
  click: this.onCancelClick
59
+ },
60
+ 'plan_form checkbox[name="autocompletable"]': {
61
+ change: this.onAutocompletableChange
56
62
  }
57
63
  });
58
64
  },
59
65
 
66
+ onAutocompletableChange: function () {
67
+ record = this.getPlanForm().getValues().autocompletable;
68
+ if(record == "on"){
69
+ this.getCallbackCheckboxCombo().hide();
70
+ } else {
71
+ this.getCallbackCheckboxCombo().show();;
72
+ }
73
+ },
74
+
60
75
  // @protected
61
76
  onAddClick: function() {
62
77
  Ext.create('TM.view.plan.FormWindow', { title: '添加计划' }).show();
@@ -107,6 +122,10 @@ Ext.define('TM.controller.Plans', {
107
122
  var record = this.getPlanForm().getRecord() ||
108
123
  Ext.create('TM.model.Plan');
109
124
 
125
+ if(attrs.autocompletable == "on") {
126
+ delete attrs["callables_attributes"];
127
+ }
128
+ attrs.autocompletable = attrs.autocompletable ? true: false;
110
129
  record.set(attrs);
111
130
  record.save({
112
131
  success: function() {
@@ -43,7 +43,7 @@ Ext.define('TM.controller.Tasks', {
43
43
  // @protected
44
44
  onDeleteClick: function(btn) {
45
45
  var select = btn.up('task_grid').getSelectionModel().getSelection()[0];
46
- if(select == null) {
46
+ if(select === null) {
47
47
  Ext.Msg.alert('提示','请选择要删除的计划任务');
48
48
  return;
49
49
  }
@@ -13,7 +13,7 @@ Ext.define('TM.helper.ApplicationHelper', {
13
13
 
14
14
  translateStatus: function(s) {
15
15
  var translations = {
16
- new: '新建',
16
+ 'new': '新建',
17
17
  in_process: '进行中',
18
18
  expired: '已过期',
19
19
  finished: '已完成'
@@ -7,6 +7,7 @@ Ext.define('TM.model.Task', {
7
7
  { name: 'task_type'},
8
8
  { name: 'data', type: 'auto' },
9
9
  { name: 'status' },
10
+ { name: 'assignee', type: 'auto', persist: false },
10
11
  { name: 'deadline', type: 'date'},
11
12
  { name: 'created_at', type: 'date' },
12
13
  { name: 'updated_at', type: 'date' }
@@ -19,5 +20,5 @@ Ext.define('TM.model.Task', {
19
20
  root: 'tasks',
20
21
  totalProperty: 'total'
21
22
  }
22
- },
23
- });
23
+ }
24
+ });
@@ -37,7 +37,7 @@ Ext.define('TM.store.Assignees', {
37
37
  var parent = this.getNodeById(assignee.getParentId(true)) || this.getRootNode();
38
38
  var node = parent.findChild('id', assignee.getId(true));
39
39
 
40
- if(!node) this.appendChildNode(parent, assignee);
40
+ if(!node) { this.appendChildNode(parent, assignee); }
41
41
  }, this);
42
42
  },
43
43
 
@@ -14,6 +14,6 @@ Ext.define('TM.store.Months',{
14
14
  { "text": "9月", 'value': '09' },
15
15
  { "text": "10月", 'value': '10' },
16
16
  { "text": "11月", 'value': '11' },
17
- { "text": "12月", 'value': '12' },
17
+ { "text": "12月", 'value': '12' }
18
18
  ]
19
- });
19
+ });
@@ -18,18 +18,20 @@ Ext.define('TM.view.assignee.TreeCombo', {
18
18
 
19
19
  getSubmitValue: function() {
20
20
  var value = [];
21
- if(!this.value) return value;
21
+ if(!this.value) { return value; }
22
22
 
23
23
  var objs = this.value.split(',');
24
24
  objs.forEach(function(i) {
25
25
  var node = this.tree.getStore().getNodeById(i);
26
26
  if(node) {
27
27
  var assignee = node.raw.record;
28
- var attrs = {
29
- assignee_id: assignee.get('id'),
30
- assignee_type: assignee.get('class_name')
31
- };
32
- value.push(attrs);
28
+ if (assignee) {
29
+ var attrs = {
30
+ assignee_id: assignee.get('id'),
31
+ assignee_type: assignee.get('class_name')
32
+ };
33
+ value.push(attrs);
34
+ }
33
35
  }
34
36
  }, this);
35
37
 
@@ -31,16 +31,17 @@ Ext.define('TM.view.plan.Form', {
31
31
  }, {
32
32
  xtype: 'assignee_treecombo',
33
33
  fieldLabel: '执行人',
34
+ allowBlank: false,
34
35
  name: 'assignables_attributes',
35
36
  store: Ext.getStore('TM.store.Assignees').toTreeStore()
36
37
  }, {
37
- fieldLabel: '类型',
38
+ fieldLabel: '周期',
38
39
  name: 'plan_type',
39
40
  store: 'TM.store.Types',
40
41
  editable: false,
41
42
  valueField: 'value',
42
43
  xtype: 'combo',
43
- blankText: '请选择类型!',
44
+ blankText: '请选择周期',
44
45
  allowBlank: false
45
46
  }, {
46
47
  fieldLabel: '横向指标',
@@ -77,13 +78,13 @@ Ext.define('TM.view.plan.Form', {
77
78
  }, {
78
79
  xtype: 'fieldset',
79
80
  itemId: 'deadline',
80
- title: '截止时间',
81
+ title: '完成时限',
81
82
  layout: {
82
83
  type: 'table',
83
84
  columns: 2
84
85
  },
85
86
  defaults: {
86
- labelAlign: 'right',
87
+ labelAlign: 'right'
87
88
  },
88
89
  items: [{
89
90
  fieldLabel: '月',
@@ -254,6 +255,7 @@ Ext.define('TM.view.plan.Form', {
254
255
  bindStore(Ext.getStore('TM.store.Days'));
255
256
 
256
257
  this.showDeadlineCombos(["month", "day", "hour", "minute"]);
258
+ this.requireDeadlineCombos(["month", "day", "hour", "minute"]);
257
259
  },
258
260
 
259
261
  // @private
@@ -264,6 +266,7 @@ Ext.define('TM.view.plan.Form', {
264
266
  bindStore(Ext.getStore('TM.store.Days'));
265
267
 
266
268
  this.showDeadlineCombos(["month", "day", "hour", "minute"]);
269
+ this.requireDeadlineCombos(["month", "day", "hour", "minute"]);
267
270
  },
268
271
 
269
272
  // @private
@@ -273,6 +276,8 @@ Ext.define('TM.view.plan.Form', {
273
276
 
274
277
  this.showDeadlineCombos(["day", "hour", "minute"]);
275
278
  this.hideDeadlineCombos(["month"]);
279
+ this.requireDeadlineCombos(["day", "hour", "minute"]);
280
+ this.allowBlankDeadlineCombos(["month"]);
276
281
  },
277
282
 
278
283
  // @private
@@ -282,12 +287,16 @@ Ext.define('TM.view.plan.Form', {
282
287
 
283
288
  this.showDeadlineCombos(["day", "hour", "minute"]);
284
289
  this.hideDeadlineCombos(["month"]);
290
+ this.requireDeadlineCombos(["day", "hour", "minute"]);
291
+ this.allowBlankDeadlineCombos(["month"]);
285
292
  },
286
293
 
287
294
  // @private
288
295
  showDailyDeadlineCombos: function() {
289
296
  this.showDeadlineCombos(["hour", "minute"]);
290
297
  this.hideDeadlineCombos(["month", "day"]);
298
+ this.requireDeadlineCombos(["hour", "minute"]);
299
+ this.allowBlankDeadlineCombos(["month","day"]);
291
300
  },
292
301
 
293
302
  // @private
@@ -309,6 +318,20 @@ Ext.define('TM.view.plan.Form', {
309
318
  }, this);
310
319
  },
311
320
 
321
+ // @private
322
+ requireDeadlineCombos: function(combos) {
323
+ combos.forEach(function(c) {
324
+ this.getDeadlineCombo('data.deadline_' + c).allowBlank = false;
325
+ }, this);
326
+ },
327
+
328
+ // @private
329
+ allowBlankDeadlineCombos: function(combos) {
330
+ combos.forEach(function(c) {
331
+ this.getDeadlineCombo('data.deadline_' + c).allowBlank = true;
332
+ }, this);
333
+ },
334
+
312
335
  // @private
313
336
  getAssigneesTreeCombo: function() {
314
337
  return this.query('assignee_treecombo')[0];
@@ -32,7 +32,7 @@ Ext.define('TM.view.plan.Grid', {
32
32
  '<table class="data">',
33
33
  '<tr>',
34
34
  '<td rowspan="3" class="title">内容</td>',
35
- '<td class="name">截止时间:</td>',
35
+ '<td class="name">完成时限:</td>',
36
36
  '<td class="value">第{[values.data.deadline_month == null ? 0 : values.data.deadline_month]}',
37
37
  '个月,第{[values.data.deadline_day == null ? 0 : values.data.deadline_day]}天,',
38
38
  '{data.deadline_hour}时{data.deadline_minute}分</td>',
@@ -45,7 +45,7 @@ Ext.define('TM.view.plan.Grid', {
45
45
  '<td class="name">纵向指标:</td>',
46
46
  '<td class="value">{[values.data.y == null ? "" : values.data.y]}</td>',
47
47
  '</tr>',
48
- '</table>',
48
+ '</table>'
49
49
  ]
50
50
  }],
51
51
 
@@ -54,7 +54,7 @@ Ext.define('TM.view.plan.Grid', {
54
54
  dataIndex: 'name',
55
55
  flex: 2
56
56
  }, {
57
- text: '类型',
57
+ text: '周期',
58
58
  dataIndex: 'plan_type',
59
59
  renderer: function(v, m, record) {
60
60
  return this.translateType(v);
@@ -19,6 +19,6 @@ Ext.define('TM.view.plan.Index', {
19
19
  width: 50
20
20
  }, {
21
21
  xtype: 'plan_grid',
22
- flex: 1,
22
+ flex: 1
23
23
  }]
24
24
  });
@@ -30,7 +30,7 @@ Ext.define('TM.view.plan.Search', {
30
30
  fieldLabel: '名称',
31
31
  name: 'q[name_cont]'
32
32
  }, {
33
- fieldLabel: '类型',
33
+ fieldLabel: '周期',
34
34
  editable: false,
35
35
  xtype: 'combo',
36
36
  store: 'TM.store.Types',
@@ -112,7 +112,7 @@ Ext.define('TM.view.plan.Search', {
112
112
  action: 'reset'
113
113
  }]
114
114
  }]
115
- }],
115
+ }]
116
116
  }]
117
117
  }],
118
118
 
@@ -38,7 +38,7 @@ Ext.define('TM.view.task.Grid', {
38
38
  dataIndex: 'name',
39
39
  flex: 2
40
40
  }, {
41
- text: '类型',
41
+ text: '周期',
42
42
  dataIndex: 'task_type',
43
43
  renderer: function(v, m, record) {
44
44
  return this.translateType(v);
@@ -52,7 +52,7 @@ Ext.define('TM.view.task.Grid', {
52
52
  },
53
53
  flex:2
54
54
  }, {
55
- text: '截止时间',
55
+ text: '完成时限',
56
56
  dataIndex: 'deadline',
57
57
  renderer: function(v, m, record) {
58
58
  return Ext.Date.format(v, 'Y年m月j日 H:i:s');
@@ -18,4 +18,4 @@ Ext.define('TM.view.task.Index', {
18
18
  xtype: 'task_grid',
19
19
  flex: 1
20
20
  }]
21
- })
21
+ });
@@ -31,7 +31,7 @@ Ext.define('TM.view.task.Search', {
31
31
  fieldLabel: '名称',
32
32
  name: 'q[name_cont]'
33
33
  }, {
34
- fieldLabel: '类型',
34
+ fieldLabel: '周期',
35
35
  editable: false,
36
36
  xtype: 'combo',
37
37
  id: 'types',
@@ -124,5 +124,5 @@ Ext.define('Ext.ux.form.CheckboxListCombo', {
124
124
  }
125
125
  }
126
126
  }
127
- },
127
+ }
128
128
  });
@@ -192,6 +192,7 @@ Ext.define('Ext.ux.TreeCombo',
192
192
  alias: 'widget.assetstree',
193
193
  hidden: true,
194
194
  minHeight: 300,
195
+ maxHeight: 500,
195
196
  rootVisible: (typeof me.rootVisible != 'undefined') ? me.rootVisible : true,
196
197
  floating: true,
197
198
  useArrows: true,
@@ -9,7 +9,7 @@ module TaskManager
9
9
  #
10
10
  # 支持的查询属性有:
11
11
  # name 计划名
12
- # plan_type 计划类型
12
+ # plan_type 计划周期
13
13
  # autocompletable 是否自动完成
14
14
  # last_task_created_at 最后任务生成时间
15
15
  # enabled_at 生效时间
@@ -9,8 +9,8 @@ module TaskManager
9
9
  #
10
10
  # 支持的查询属性有:
11
11
  # name 任务名
12
- # task_type 任务类型
13
- # deadline 截止时间
12
+ # task_type 任务周期
13
+ # deadline 完成时限
14
14
  # status 状态
15
15
  # updated_at 完成时间
16
16
  #
@@ -53,11 +53,6 @@ module TaskManager
53
53
  data.symbolize_keys!
54
54
 
55
55
  reminding_at = default_deadline.ago(begin_to_remind * 60)
56
- if autocompletable
57
- status, finished_at = :finished, Time.now
58
- else
59
- status, finished_at = :new, nil
60
- end
61
56
 
62
57
  Task.create! do |t|
63
58
  t.name = name
@@ -65,8 +60,9 @@ module TaskManager
65
60
  t.task_type = plan_type
66
61
  t.deadline = calculate_deadline(plan_type, data)
67
62
  t.reminding_at = reminding_at
68
- t.status = status
69
- t.finished_at = finished_at
63
+ t.status = :new
64
+ t.finished_at = nil
65
+ t.autocompletable = autocompletable
70
66
  t.create_assignable(
71
67
  assignee_id: a.assignee_id,
72
68
  assignee_type: a.assignee_type,
@@ -13,7 +13,8 @@ module TaskManager
13
13
 
14
14
  default_value_for :status, :new
15
15
 
16
- attr_accessible :data, :deadline, :name, :reminding_at, :status, :task_type, :finished_at
16
+ attr_accessible :data, :deadline, :name, :reminding_at, :status,
17
+ :task_type, :finished_at, :autocompletable
17
18
 
18
19
  validates_presence_of :name, :task_type, :status, :assignable, :deadline
19
20
 
@@ -76,6 +77,10 @@ module TaskManager
76
77
  def remindable
77
78
  active.where("reminding_at <= ?", Time.now)
78
79
  end
80
+
81
+ def autocompletable
82
+ where(autocompletable: true)
83
+ end
79
84
  end
80
85
  end
81
86
  end
@@ -4,6 +4,7 @@ class CreateTaskManagerTasks < ActiveRecord::Migration
4
4
  t.string :name
5
5
  t.string :task_type
6
6
  t.string :status
7
+ t.boolean :autocompletable
7
8
 
8
9
  t.hstore :data
9
10
 
@@ -34,4 +34,8 @@ module TaskManager
34
34
 
35
35
  tasks
36
36
  end
37
+
38
+ def self.finish_autocompletable_tasks
39
+ Task.autocompletable.just_expired.each(&:finish)
40
+ end
37
41
  end
@@ -1,3 +1,3 @@
1
1
  module TaskManager
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: task-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-06 00:00:00.000000000 Z
12
+ date: 2013-01-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -324,7 +324,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
324
324
  version: '0'
325
325
  segments:
326
326
  - 0
327
- hash: -419505164111857855
327
+ hash: 3025342267253612574
328
328
  required_rubygems_version: !ruby/object:Gem::Requirement
329
329
  none: false
330
330
  requirements:
@@ -333,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
333
333
  version: '0'
334
334
  segments:
335
335
  - 0
336
- hash: -419505164111857855
336
+ hash: 3025342267253612574
337
337
  requirements: []
338
338
  rubyforge_project:
339
339
  rubygems_version: 1.8.24