1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-12-04 05:22:38 +03:00

Sorting: Added sort set form manager UI JS

Extracted much code to be shared with the shelf books management UI
This commit is contained in:
Dan Brown
2025-02-04 15:14:22 +00:00
parent bf8a84a8b1
commit d28278bba6
13 changed files with 168 additions and 103 deletions

View File

@@ -15,21 +15,21 @@ use Illuminate\Database\Eloquent\Model;
class SortSet extends Model
{
/**
* @return SortSetOption[]
* @return SortSetOperation[]
*/
public function getOptions(): array
public function getOperations(): array
{
$strOptions = explode(',', $this->sequence);
$options = array_map(fn ($val) => SortSetOption::tryFrom($val), $strOptions);
$options = array_map(fn ($val) => SortSetOperation::tryFrom($val), $strOptions);
return array_filter($options);
}
/**
* @param SortSetOption[] $options
* @param SortSetOperation[] $options
*/
public function setOptions(array $options): void
public function setOperations(array $options): void
{
$values = array_map(fn (SortSetOption $opt) => $opt->value, $options);
$values = array_map(fn (SortSetOperation $opt) => $opt->value, $options);
$this->sequence = implode(',', $values);
}
}