refactor: Group and sort fields in StackForm by service name and password status
This commit is contained in:
@@ -33,7 +33,7 @@ class StackForm extends Component
|
||||
$key = data_get($field, 'key');
|
||||
$value = data_get($field, 'value');
|
||||
$rules = data_get($field, 'rules', 'nullable');
|
||||
$isPassword = data_get($field, 'isPassword');
|
||||
$isPassword = data_get($field, 'isPassword', false);
|
||||
$this->fields->put($key, [
|
||||
'serviceName' => $serviceName,
|
||||
'key' => $key,
|
||||
@@ -47,7 +47,15 @@ class StackForm extends Component
|
||||
$this->validationAttributes["fields.$key.value"] = $fieldKey;
|
||||
}
|
||||
}
|
||||
$this->fields = $this->fields->sortBy('name');
|
||||
$this->fields = $this->fields->groupBy('serviceName')->map(function ($group) {
|
||||
return $group->sortBy(function ($field) {
|
||||
return data_get($field, 'isPassword') ? 1 : 0;
|
||||
})->mapWithKeys(function ($field) {
|
||||
return [$field['key'] => $field];
|
||||
});
|
||||
})->flatMap(function ($group) {
|
||||
return $group;
|
||||
});
|
||||
}
|
||||
|
||||
public function saveCompose($raw)
|
||||
|
Reference in New Issue
Block a user