task-manager 0.1.4 → 0.1.5

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.
@@ -19,8 +19,15 @@ Ext.define('TM.controller.Plans', {
19
19
  }, {
20
20
  ref: 'planForm',
21
21
  selector: 'plan_form'
22
+ }, {
23
+ ref: 'planGrid',
24
+ selector: 'plan_grid'
22
25
  }],
23
26
 
27
+ index: function() {
28
+ this.render('TM.view.plan.Index');
29
+ },
30
+
24
31
  init: function() {
25
32
  this.control({
26
33
  'plan_search button[action="query"]': {
@@ -38,6 +45,9 @@ Ext.define('TM.controller.Plans', {
38
45
  'plan_grid button[action="delete"]': {
39
46
  click: this.onDeleteClick
40
47
  },
48
+ 'plan_grid': {
49
+ render: this.onGridRender
50
+ },
41
51
  'plan_form button[action="save"]': {
42
52
  click: this.onSaveClick
43
53
  },
@@ -47,10 +57,12 @@ Ext.define('TM.controller.Plans', {
47
57
  });
48
58
  },
49
59
 
60
+ // @protected
50
61
  onAddClick: function() {
51
62
  Ext.create('TM.view.plan.FormWindow', { title: '添加计划' }).show();
52
63
  },
53
64
 
65
+ // @protected
54
66
  onEditClick: function(btn) {
55
67
  var length = btn.up('plan_grid').getSelectionModel().getSelection().length;
56
68
  if (length == 0) {
@@ -70,6 +82,7 @@ Ext.define('TM.controller.Plans', {
70
82
  this.getPlanForm().loadRecord(record);
71
83
  },
72
84
 
85
+ // @protected
73
86
  onDeleteClick: function(btn) {
74
87
  var select = btn.up('plan_grid').getSelectionModel().getSelection()[0];
75
88
  if(select == null) {
@@ -87,6 +100,7 @@ Ext.define('TM.controller.Plans', {
87
100
  });
88
101
  },
89
102
 
103
+ // @protected
90
104
  onSaveClick: function(btn) {
91
105
  var self = this;
92
106
  var attrs = this.getPlanForm().getValues();
@@ -97,6 +111,8 @@ Ext.define('TM.controller.Plans', {
97
111
  record.save({
98
112
  success: function() {
99
113
  Ext.Msg.alert('提示', '保存计划成功!');
114
+
115
+ self.getPlanGrid().reconfigure();
100
116
  self.getPlanFormWindow().close();
101
117
  },
102
118
  failure: function() {
@@ -105,20 +121,26 @@ Ext.define('TM.controller.Plans', {
105
121
  });
106
122
  },
107
123
 
124
+ // @protected
108
125
  onCancelClick: function(btn) {
109
126
  this.getPlanFormWindow().close();
110
127
  },
111
128
 
129
+ // @protected
112
130
  onQueryClick: function(btn) {
113
131
  var params = this.getSearchForm().getValues();
114
132
  Ext.getStore('TM.store.Plans').load({ params: params });
115
133
  },
116
134
 
135
+ // @protected
117
136
  onSearchResetClick: function(btn) {
118
137
  this.getSearchForm().getForm().reset();
119
138
  },
120
139
 
121
- index: function() {
122
- this.render('TM.view.plan.Index');
140
+ // @protected
141
+ onGridRender: function(grid) {
142
+ if(grid.getStore().getCount() <= 0) {
143
+ grid.getStore().load();
144
+ }
123
145
  }
124
146
  });
@@ -8,6 +8,10 @@ Ext.define('TM.controller.Tasks', {
8
8
  selector: 'task_search'
9
9
  }],
10
10
 
11
+ index: function() {
12
+ this.render('TM.view.task.Index');
13
+ },
14
+
11
15
  init: function() {
12
16
  this.control({
13
17
  'task_search button[action="query"]': {
@@ -18,19 +22,25 @@ Ext.define('TM.controller.Tasks', {
18
22
  },
19
23
  'task_grid button[action="delete"]': {
20
24
  click: this.onDeleteClick
21
- }
25
+ },
26
+ 'task_grid': {
27
+ render: this.onGridRender
28
+ }
22
29
  });
23
30
  },
24
31
 
32
+ // @protected
25
33
  onQueryClick: function(btn) {
26
34
  var params = this.getSearchForm().getValues();
27
35
  Ext.getStore('TM.store.Tasks').load({ params: params });
28
36
  },
29
37
 
38
+ // @protected
30
39
  onSearchResetClick: function(btn) {
31
40
  this.getSearchForm().getForm().reset();
32
41
  },
33
42
 
43
+ // @protected
34
44
  onDeleteClick: function(btn) {
35
45
  var select = btn.up('task_grid').getSelectionModel().getSelection()[0];
36
46
  if(select == null) {
@@ -50,7 +60,10 @@ Ext.define('TM.controller.Tasks', {
50
60
  });
51
61
  },
52
62
 
53
- index: function() {
54
- this.render('TM.view.task.Index');
55
- }
63
+ // @protected
64
+ onGridRender: function(grid) {
65
+ if(grid.getStore().getCount() <= 0) {
66
+ grid.getStore().load();
67
+ }
68
+ }
56
69
  });
@@ -1,6 +1,5 @@
1
1
  Ext.define('TM.store.Plans', {
2
2
  extend: 'Ext.data.Store',
3
3
 
4
- autoLoad: true,
5
4
  model: 'TM.model.Plan'
6
5
  });
@@ -1,6 +1,5 @@
1
1
  Ext.define('TM.store.Tasks',{
2
2
  extend: 'Ext.data.Store',
3
3
 
4
- autoLoad: true,
5
4
  model: 'TM.model.Task'
6
- });
5
+ });
@@ -2,6 +2,7 @@ Ext.define('TM.view.assignee.TreeCombo', {
2
2
  xtype: 'assignee_treecombo',
3
3
  extend: 'Ext.ux.TreeCombo',
4
4
  editable: false,
5
+ rootVisible: false,
5
6
 
6
7
  setValue: function(valueInit) {
7
8
  if(typeof valueInit === 'object') {
@@ -5,7 +5,7 @@ Ext.define('TM.view.callback.CheckboxCombo', {
5
5
  getSubmitValue: function() {
6
6
  var callbacks = [];
7
7
 
8
- Ext.Array.forEach(this.value, function(c, i) {
8
+ Ext.Array.forEach(this.value || [], function(c, i) {
9
9
  callbacks.push({
10
10
  callback_id: c,
11
11
  callback_type: Ext.getStore('TM.store.Callbacks').getAt(0).get('class_name')
@@ -2,10 +2,6 @@ Ext.define('TM.view.plan.Form', {
2
2
  extend: 'Ext.form.Panel',
3
3
  xtype: 'plan_form',
4
4
 
5
- //requires: [
6
- //'Ext.ux.TreeCombo',
7
- //],
8
-
9
5
  defaultPlanType: 'yearly',
10
6
  defaultBeginToRemind: 0,
11
7
 
@@ -29,28 +25,30 @@ Ext.define('TM.view.plan.Form', {
29
25
  },
30
26
 
31
27
  items: [{
32
- fieldLabel: '计划名称',
28
+ fieldLabel: '名称',
33
29
  name: 'name',
34
30
  allowBlank: false
35
31
  }, {
36
32
  xtype: 'assignee_treecombo',
37
- fieldLabel: '计划执行人',
33
+ fieldLabel: '执行人',
38
34
  name: 'assignables_attributes',
39
35
  store: Ext.getStore('TM.store.Assignees').toTreeStore()
40
36
  }, {
41
- fieldLabel: '计划类型',
37
+ fieldLabel: '类型',
42
38
  name: 'plan_type',
43
39
  store: 'TM.store.Types',
44
40
  editable: false,
45
41
  valueField: 'value',
46
42
  xtype: 'combo',
47
- blankText: '请选择计划类型!',
43
+ blankText: '请选择类型!',
48
44
  allowBlank: false
49
45
  }, {
50
46
  fieldLabel: '横向指标',
47
+ emptyText: '请用逗号分割指标项',
51
48
  name: 'data.x'
52
49
  }, {
53
50
  fieldLabel: '纵向指标',
51
+ emptyText: '请用逗号分割指标项',
54
52
  name: 'data.y'
55
53
  }, {
56
54
  fieldLabel: '生效时间',
@@ -60,15 +58,14 @@ Ext.define('TM.view.plan.Form', {
60
58
  format: 'Y/m/d',
61
59
  name: 'enabled_at'
62
60
  }, {
63
- fieldLabel: '完成前几天提醒',
64
- emptyText: '计划完成前多少天开始提醒,此处为倒计时。',
61
+ fieldLabel: '提前几天提醒',
65
62
  name: 'begin_to_remind'
66
63
  }, {
67
64
  fieldLabel: '是否自动完成',
68
65
  xtype: 'checkbox',
69
66
  name: 'autocompletable'
70
67
  }, {
71
- fieldLabel: '超时回调',
68
+ fieldLabel: '逾期处理',
72
69
  xtype: 'callback_checkboxcombo',
73
70
  editable: false,
74
71
  name: 'callables_attributes',
@@ -80,7 +77,7 @@ Ext.define('TM.view.plan.Form', {
80
77
  }, {
81
78
  xtype: 'fieldset',
82
79
  itemId: 'deadline',
83
- title: '计划完成截至时限',
80
+ title: '截止时间',
84
81
  layout: {
85
82
  type: 'table',
86
83
  columns: 2
@@ -142,6 +139,8 @@ Ext.define('TM.view.plan.Form', {
142
139
  delete values['data.' + name];
143
140
  }, this);
144
141
 
142
+ values.begin_to_remind = values.begin_to_remind * 24 * 60;
143
+
145
144
  return values;
146
145
  },
147
146
 
@@ -158,6 +157,8 @@ Ext.define('TM.view.plan.Form', {
158
157
  this.query('textfield[name="data.' + name + '"]')[0].setValue(record.get('data')[name]);
159
158
  }, this);
160
159
 
160
+ this.query('textfield[name="begin_to_remind"]')[0].setValue(record.get('begin_to_remind') / (24 * 60));
161
+
161
162
  this.checkSelectedAssignees(record.get('assignees'));
162
163
  this.checkSelectedCallbacks(record.get('callbacks'));
163
164
  },
@@ -210,7 +211,6 @@ Ext.define('TM.view.plan.Form', {
210
211
  }
211
212
  }, this);
212
213
 
213
- //console.log(values);
214
214
  this.getAssigneesTreeCombo().setValue(values);
215
215
  },
216
216
 
@@ -69,7 +69,7 @@ Ext.define('TM.view.plan.Grid', {
69
69
  },
70
70
  flex: 3
71
71
  }, {
72
- text: '超时回调',
72
+ text: '逾期处理',
73
73
  renderer: function(v, m, record) {
74
74
  var names = new Array();
75
75
  Ext.Array.forEach(record.get('callbacks'), function(callback, index) {names.push(callback.name)});
@@ -89,8 +89,11 @@ Ext.define('TM.view.plan.Grid', {
89
89
  },
90
90
  flex: 1
91
91
  }, {
92
- text: '开始提醒天数',
92
+ text: '提前几天提醒',
93
93
  dataIndex: 'begin_to_remind',
94
+ renderer: function(v, m, record) {
95
+ return v / (24 * 60);
96
+ },
94
97
  flex: 1
95
98
  }]
96
99
  });
@@ -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');
@@ -120,7 +120,6 @@ Ext.define('Ext.ux.form.CheckboxListCombo', {
120
120
  }
121
121
  me.resumeEvents();// resume events, though selectAll & deselectAll send them anyway
122
122
  me.view.resumeEvents();
123
- console.log("CheckboxComboList.changed: " + allState + " / " + nChecked);
124
123
  }
125
124
  }
126
125
  }
@@ -61,7 +61,7 @@ module TaskManager
61
61
 
62
62
  Task.create! do |t|
63
63
  t.name = name
64
- t.data = { x: data[:x], y: data[:y] }
64
+ t.data = data.select{ |k, v| !(k.to_s.start_with?('deadline_')) }
65
65
  t.task_type = plan_type
66
66
  t.deadline = calculate_deadline(plan_type, data)
67
67
  t.reminding_at = reminding_at
@@ -118,7 +118,9 @@ module TaskManager
118
118
  when :yearly then now.beginning_of_year
119
119
  end
120
120
 
121
- squeel{ (plan_type == type) & (last_task_created_at <= beginning_at) & (enabled_at <= now) }
121
+ squeel{ (plan_type == type) &
122
+ ((last_task_created_at <= beginning_at) | (last_task_created_at == nil)) &
123
+ (enabled_at <= now) }
122
124
  end
123
125
  end
124
126
  end
@@ -1,3 +1,3 @@
1
1
  module TaskManager
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
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.4
4
+ version: 0.1.5
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-03 00:00:00.000000000 Z
12
+ date: 2012-12-06 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: 2162932120880694104
327
+ hash: -419505164111857855
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: 2162932120880694104
336
+ hash: -419505164111857855
337
337
  requirements: []
338
338
  rubyforge_project:
339
339
  rubygems_version: 1.8.24