Skip to content

Commit accdb32

Browse files
committed
field&sprintname
1 parent a5c9075 commit accdb32

File tree

6 files changed

+69
-11
lines changed

6 files changed

+69
-11
lines changed

app/Customization/Eloquent/Field.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class Field extends Model
1717
'description',
1818
'defaultValue',
1919
'optionValues',
20+
'minValue',
21+
'maxValue',
22+
'maxLength',
2023
'project_key'
2124
);
2225
}

app/Http/Controllers/FieldController.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class FieldController extends Controller
7777

7878
private $all_types = [
7979
'Tags',
80+
'Integer',
8081
'Number',
8182
'Text',
8283
'TextArea',
@@ -303,6 +304,32 @@ public function update(Request $request, $project_key, $id)
303304
}
304305
}
305306

307+
$mmTypes = [ 'Number', 'Integer' ];
308+
if (in_array($field->type, $mmTypes))
309+
{
310+
$maxValue = $request->input('maxValue');
311+
if (isset($maxValue))
312+
{
313+
$updValues['maxValue'] = ($maxValue === '' ? '' : ($maxValue + 0));
314+
}
315+
316+
$minValue = $request->input('minValue');
317+
if (isset($minValue))
318+
{
319+
$updValues['minValue'] = ($minValue === '' ? '' : ($minValue + 0));
320+
}
321+
}
322+
323+
$mlTypes = [ 'Text', 'TextArea' ];
324+
if (in_array($field->type, $mlTypes))
325+
{
326+
$maxLength = $request->input('maxLength');
327+
if (isset($maxLength))
328+
{
329+
$updValues['maxLength'] = ($maxLength === '' ? '' : intval($maxLength));
330+
}
331+
}
332+
306333
$field->fill($updValues + $request->except(['project_key', 'key', 'type']))->save();
307334

308335
Event::fire(new FieldChangeEvent($id));

app/Http/Controllers/IssueController.php

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public function search(Request $request, $project_key)
258258
$limit = 10;
259259
}
260260

261-
$query->take($limit)->orderBy('created_at', 'asc');
261+
$query->take($limit)->orderBy('created_at', 'desc');
262262
$issues = $query->get();
263263
return Response()->json([ 'ecode' => 0, 'data' => parent::arrange($issues) ]);
264264
}
@@ -624,11 +624,11 @@ public function getOptions($project_key)
624624
// get project types
625625
$types = Provider::getTypeListExt($project_key, [ 'user' => $users, 'assignee' => $assignees, 'state' => $states, 'resolution' => $resolutions, 'priority' => $priorities, 'version' => $versions, 'module' => $modules, 'epic' => $epics, 'labels' => $labels ]);
626626
// get project sprints
627-
$sprint_nos = [];
627+
$new_sprints = [];
628628
$sprints = Provider::getSprintList($project_key);
629629
foreach ($sprints as $sprint)
630630
{
631-
$sprint_nos[] = strval($sprint['no']);
631+
$new_sprints[] = [ 'no' => $sprint['no'], 'name' => $sprint['name'] ];
632632
}
633633
// get defined fields
634634
$fields = Provider::getFieldList($project_key);
@@ -654,7 +654,7 @@ public function getOptions($project_key)
654654
'labels' => $labels,
655655
'versions' => $versions,
656656
'epics' => $epics,
657-
'sprints' => $sprint_nos,
657+
'sprints' => $new_sprints,
658658
'filters' => $filters,
659659
'display_columns' => $display_columns,
660660
'timetrack' => $timetrack,
@@ -2130,19 +2130,26 @@ public function getOptionsForExport($project_key)
21302130
}
21312131

21322132
$modules = [];
2133-
$module_list = Provider::getModuleList($project_key);
2133+
$module_list = Provider::getModuleList($project_key);
21342134
foreach ($module_list as $module)
21352135
{
21362136
$modules[$module->id] = $module->name;
21372137
}
21382138

21392139
$epics = [];
2140-
$epic_list = Provider::getEpicList($project_key);
2140+
$epic_list = Provider::getEpicList($project_key);
21412141
foreach ($epic_list as $epic)
21422142
{
21432143
$epics[$epic['_id']] = $epic['name'];
21442144
}
21452145

2146+
$sprints = [];
2147+
$sprint_list = Provider::getSprintList($project_key);
2148+
foreach ($sprint_list as $sprint)
2149+
{
2150+
$sprints[$sprint['no']] = $sprint['name'];
2151+
}
2152+
21462153
$fields = [];
21472154
$field_list = Provider::getFieldList($project_key);
21482155
foreach ($field_list as $field)
@@ -2177,6 +2184,7 @@ public function getOptionsForExport($project_key)
21772184
'versions' => $versions,
21782185
'modules' => $modules,
21792186
'epics' => $epics,
2187+
'sprints' => $sprints,
21802188
'fields' => $fields,
21812189
];
21822190

@@ -2917,7 +2925,15 @@ public function export($project_key, $export_fields, $issues)
29172925
}
29182926
else if ($fk == 'sprints')
29192927
{
2920-
$tmp[] = 'Sprint ' . implode(',', $issue[$fk]);
2928+
$new_sprints = [];
2929+
foreach ($issue[$fk] as $sn)
2930+
{
2931+
if (isset($sprints[$sn]))
2932+
{
2933+
$new_sprints[] = $sprints[$sn];
2934+
}
2935+
}
2936+
$tmp[] = implode(',', $new_sprints);
29212937
}
29222938
else if ($fk == 'labels')
29232939
{
@@ -3168,15 +3184,15 @@ public function batchUpdate($project_key, $ids, $values)
31683184

31693185
if ($field->type == 'DateTimePicker' || $field->type == 'DatePicker')
31703186
{
3171-
if ($this->isTimestamp($val) === false)
3187+
if ($val && $this->isTimestamp($val) === false)
31723188
{
31733189
throw new \UnexpectedValueException('the format of datepicker field is incorrect.', -11122);
31743190
}
31753191
$updValues[$key] = $val;
31763192
}
31773193
else if ($field->type == 'TimeTracking')
31783194
{
3179-
if (!$this->ttCheck($val))
3195+
if ($val && !$this->ttCheck($val))
31803196
{
31813197
throw new \UnexpectedValueException('the format of timetracking field is incorrect.', -11102);
31823198
}
@@ -3207,6 +3223,17 @@ public function batchUpdate($project_key, $ids, $values)
32073223
}
32083224
$updValues[$key . '_ids'] = $new_user_ids;
32093225
}
3226+
else if ($field->type === 'Number' || $field->type === 'Integer')
3227+
{
3228+
if ($val === '')
3229+
{
3230+
$updValues[$key] = '';
3231+
}
3232+
else
3233+
{
3234+
$updValues[$key] = $field->type === 'Number' ? floatVal($val) : intVal($val);
3235+
}
3236+
}
32103237
else
32113238
{
32123239
$updValues[$key] = $val;

app/Http/Controllers/ScreenController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function update(Request $request, $project_key, $id)
142142
}
143143
else
144144
{
145-
$new_schema[] = Field::Find($field_id, ['name', 'key', 'type', 'defaultValue', 'optionValues'])->toArray();
145+
$new_schema[] = Field::Find($field_id, ['name', 'key', 'type', 'defaultValue', 'optionValues', 'minValue', 'maxValue', 'maxLength'])->toArray();
146146
}
147147
}
148148
$screen->schema = $new_schema;

app/Http/routes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@
255255
Route::post('sprint', 'SprintController@store');
256256
Route::post('sprint/moveissue', 'SprintController@moveIssue');
257257
Route::post('sprint/{no}/publish', 'SprintController@publish');
258+
Route::put('sprint/{no}', 'SprintController@update');
258259
Route::post('sprint/{no}/complete', 'SprintController@complete');
259260
Route::get('sprint/{no}/log', 'SprintController@getLog');
260261
Route::get('sprint/{no}', 'SprintController@show');

app/Listeners/FieldConfigChangeListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function updateSchema($field_id, $flag)
7373

7474
if ($flag == 1)
7575
{
76-
$new_field = Field::Find($field_id, ['name', 'key', 'type', 'applyToTypes', 'defaultValue', 'optionValues'])->toArray();
76+
$new_field = Field::Find($field_id, ['name', 'key', 'type', 'applyToTypes', 'defaultValue', 'optionValues', 'minValue', 'maxValue', 'maxLength'])->toArray();
7777
if (isset($field['required']) && $field['required'])
7878
{
7979
$new_field['required'] = true;

0 commit comments

Comments
 (0)