mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-12 16:08:08 +00:00
Merge branch 'add-priority' into development
This commit is contained in:
commit
391478465a
14 changed files with 32 additions and 39 deletions
app
Api
Entities
dev/api
requests
responses
tests/Api
|
@ -10,7 +10,7 @@ class ApiEntityListFormatter
|
||||||
* The list to be formatted.
|
* The list to be formatted.
|
||||||
* @var Entity[]
|
* @var Entity[]
|
||||||
*/
|
*/
|
||||||
protected $list = [];
|
protected array $list = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The fields to show in the formatted data.
|
* The fields to show in the formatted data.
|
||||||
|
@ -19,9 +19,9 @@ class ApiEntityListFormatter
|
||||||
* will be used for the resultant value. A null return value will omit the property.
|
* will be used for the resultant value. A null return value will omit the property.
|
||||||
* @var array<string|int, string|callable>
|
* @var array<string|int, string|callable>
|
||||||
*/
|
*/
|
||||||
protected $fields = [
|
protected array $fields = [
|
||||||
'id', 'name', 'slug', 'book_id', 'chapter_id',
|
'id', 'name', 'slug', 'book_id', 'chapter_id', 'draft',
|
||||||
'draft', 'template', 'created_at', 'updated_at',
|
'template', 'priority', 'created_at', 'updated_at',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(array $list)
|
public function __construct(array $list)
|
||||||
|
|
|
@ -19,12 +19,14 @@ class ChapterApiController extends ApiController
|
||||||
'name' => ['required', 'string', 'max:255'],
|
'name' => ['required', 'string', 'max:255'],
|
||||||
'description' => ['string', 'max:1000'],
|
'description' => ['string', 'max:1000'],
|
||||||
'tags' => ['array'],
|
'tags' => ['array'],
|
||||||
|
'priority' => ['integer'],
|
||||||
],
|
],
|
||||||
'update' => [
|
'update' => [
|
||||||
'book_id' => ['integer'],
|
'book_id' => ['integer'],
|
||||||
'name' => ['string', 'min:1', 'max:255'],
|
'name' => ['string', 'min:1', 'max:255'],
|
||||||
'description' => ['string', 'max:1000'],
|
'description' => ['string', 'max:1000'],
|
||||||
'tags' => ['array'],
|
'tags' => ['array'],
|
||||||
|
'priority' => ['integer'],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ class PageApiController extends ApiController
|
||||||
'html' => ['required_without:markdown', 'string'],
|
'html' => ['required_without:markdown', 'string'],
|
||||||
'markdown' => ['required_without:html', 'string'],
|
'markdown' => ['required_without:html', 'string'],
|
||||||
'tags' => ['array'],
|
'tags' => ['array'],
|
||||||
|
'priority' => ['integer'],
|
||||||
],
|
],
|
||||||
'update' => [
|
'update' => [
|
||||||
'book_id' => ['integer'],
|
'book_id' => ['integer'],
|
||||||
|
@ -29,6 +30,7 @@ class PageApiController extends ApiController
|
||||||
'html' => ['string'],
|
'html' => ['string'],
|
||||||
'markdown' => ['string'],
|
'markdown' => ['string'],
|
||||||
'tags' => ['array'],
|
'tags' => ['array'],
|
||||||
|
'priority' => ['integer'],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,9 @@ use Exception;
|
||||||
|
|
||||||
class ChapterRepo
|
class ChapterRepo
|
||||||
{
|
{
|
||||||
protected $baseRepo;
|
public function __construct(
|
||||||
|
protected BaseRepo $baseRepo
|
||||||
/**
|
) {
|
||||||
* ChapterRepo constructor.
|
|
||||||
*/
|
|
||||||
public function __construct(BaseRepo $baseRepo)
|
|
||||||
{
|
|
||||||
$this->baseRepo = $baseRepo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,24 +23,12 @@ use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
|
|
||||||
class PageRepo
|
class PageRepo
|
||||||
{
|
{
|
||||||
protected BaseRepo $baseRepo;
|
|
||||||
protected RevisionRepo $revisionRepo;
|
|
||||||
protected ReferenceStore $referenceStore;
|
|
||||||
protected ReferenceUpdater $referenceUpdater;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PageRepo constructor.
|
|
||||||
*/
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
BaseRepo $baseRepo,
|
protected BaseRepo $baseRepo,
|
||||||
RevisionRepo $revisionRepo,
|
protected RevisionRepo $revisionRepo,
|
||||||
ReferenceStore $referenceStore,
|
protected ReferenceStore $referenceStore,
|
||||||
ReferenceUpdater $referenceUpdater
|
protected ReferenceUpdater $referenceUpdater
|
||||||
) {
|
) {
|
||||||
$this->baseRepo = $baseRepo;
|
|
||||||
$this->revisionRepo = $revisionRepo;
|
|
||||||
$this->referenceStore = $referenceStore;
|
|
||||||
$this->referenceUpdater = $referenceUpdater;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -159,13 +147,11 @@ class PageRepo
|
||||||
*/
|
*/
|
||||||
public function publishDraft(Page $draft, array $input): Page
|
public function publishDraft(Page $draft, array $input): Page
|
||||||
{
|
{
|
||||||
$this->updateTemplateStatusAndContentFromInput($draft, $input);
|
|
||||||
$this->baseRepo->update($draft, $input);
|
|
||||||
|
|
||||||
$draft->draft = false;
|
$draft->draft = false;
|
||||||
$draft->revision_count = 1;
|
$draft->revision_count = 1;
|
||||||
$draft->priority = $this->getNewPriority($draft);
|
$draft->priority = $this->getNewPriority($draft);
|
||||||
$draft->save();
|
$this->updateTemplateStatusAndContentFromInput($draft, $input);
|
||||||
|
$this->baseRepo->update($draft, $input);
|
||||||
|
|
||||||
$this->revisionRepo->storeNewForPage($draft, trans('entities.pages_initial_revision'));
|
$this->revisionRepo->storeNewForPage($draft, trans('entities.pages_initial_revision'));
|
||||||
$this->referenceStore->updateForPage($draft);
|
$this->referenceStore->updateForPage($draft);
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
"book_id": 1,
|
"book_id": 1,
|
||||||
"name": "My fantastic new chapter",
|
"name": "My fantastic new chapter",
|
||||||
"description": "This is a great new chapter that I've created via the API",
|
"description": "This is a great new chapter that I've created via the API",
|
||||||
|
"priority": 15,
|
||||||
"tags": [
|
"tags": [
|
||||||
{"name": "Category", "value": "Top Content"},
|
{"name": "Category", "value": "Top Content"},
|
||||||
{"name": "Rating", "value": "Highest"}
|
{"name": "Rating", "value": "Highest"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
"book_id": 1,
|
"book_id": 1,
|
||||||
"name": "My fantastic updated chapter",
|
"name": "My fantastic updated chapter",
|
||||||
"description": "This is an updated chapter that I've altered via the API",
|
"description": "This is an updated chapter that I've altered via the API",
|
||||||
|
"priority": 16,
|
||||||
"tags": [
|
"tags": [
|
||||||
{"name": "Category", "value": "Kinda Good Content"},
|
{"name": "Category", "value": "Kinda Good Content"},
|
||||||
{"name": "Rating", "value": "Medium"}
|
{"name": "Rating", "value": "Medium"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
"book_id": 1,
|
"book_id": 1,
|
||||||
"name": "My API Page",
|
"name": "My API Page",
|
||||||
"html": "<p>my new API page</p>",
|
"html": "<p>my new API page</p>",
|
||||||
|
"priority": 15,
|
||||||
"tags": [
|
"tags": [
|
||||||
{"name": "Category", "value": "Not Bad Content"},
|
{"name": "Category", "value": "Not Bad Content"},
|
||||||
{"name": "Rating", "value": "Average"}
|
{"name": "Rating", "value": "Average"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
"chapter_id": 1,
|
"chapter_id": 1,
|
||||||
"name": "My updated API Page",
|
"name": "My updated API Page",
|
||||||
"html": "<p>my new API page - Updated</p>",
|
"html": "<p>my new API page - Updated</p>",
|
||||||
|
"priority": 16,
|
||||||
"tags": [
|
"tags": [
|
||||||
{"name": "Category", "value": "API Examples"},
|
{"name": "Category", "value": "API Examples"},
|
||||||
{"name": "Rating", "value": "Alright"}
|
{"name": "Rating", "value": "Alright"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"slug": "my-fantastic-new-chapter",
|
"slug": "my-fantastic-new-chapter",
|
||||||
"name": "My fantastic new chapter",
|
"name": "My fantastic new chapter",
|
||||||
"description": "This is a great new chapter that I've created via the API",
|
"description": "This is a great new chapter that I've created via the API",
|
||||||
"priority": 6,
|
"priority": 15,
|
||||||
"created_by": 1,
|
"created_by": 1,
|
||||||
"updated_by": 1,
|
"updated_by": 1,
|
||||||
"owned_by": 1,
|
"owned_by": 1,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"slug": "my-fantastic-updated-chapter",
|
"slug": "my-fantastic-updated-chapter",
|
||||||
"name": "My fantastic updated chapter",
|
"name": "My fantastic updated chapter",
|
||||||
"description": "This is an updated chapter that I've altered via the API",
|
"description": "This is an updated chapter that I've altered via the API",
|
||||||
"priority": 7,
|
"priority": 16,
|
||||||
"created_at": "2020-05-22T23:03:35.000000Z",
|
"created_at": "2020-05-22T23:03:35.000000Z",
|
||||||
"updated_at": "2020-05-22T23:07:20.000000Z",
|
"updated_at": "2020-05-22T23:07:20.000000Z",
|
||||||
"created_by": 1,
|
"created_by": 1,
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"slug": "my-api-page",
|
"slug": "my-api-page",
|
||||||
"html": "<p id=\"bkmrk-my-new-api-page\">my new API page</p>",
|
"html": "<p id=\"bkmrk-my-new-api-page\">my new API page</p>",
|
||||||
"raw_html": "<p id=\"bkmrk-my-new-api-page\">my new API page</p>",
|
"raw_html": "<p id=\"bkmrk-my-new-api-page\">my new API page</p>",
|
||||||
"priority": 14,
|
"priority": 15,
|
||||||
"created_at": "2020-11-28T15:01:39.000000Z",
|
"created_at": "2020-11-28T15:01:39.000000Z",
|
||||||
"updated_at": "2020-11-28T15:01:39.000000Z",
|
"updated_at": "2020-11-28T15:01:39.000000Z",
|
||||||
"created_by": {
|
"created_by": {
|
||||||
|
|
|
@ -45,6 +45,7 @@ class ChaptersApiTest extends TestCase
|
||||||
'value' => 'tagvalue',
|
'value' => 'tagvalue',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'priority' => 15,
|
||||||
];
|
];
|
||||||
|
|
||||||
$resp = $this->postJson($this->baseEndpoint, $details);
|
$resp = $this->postJson($this->baseEndpoint, $details);
|
||||||
|
@ -137,6 +138,7 @@ class ChaptersApiTest extends TestCase
|
||||||
'value' => 'freshtagval',
|
'value' => 'freshtagval',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'priority' => 15,
|
||||||
];
|
];
|
||||||
|
|
||||||
$resp = $this->putJson($this->baseEndpoint . "/{$chapter->id}", $details);
|
$resp = $this->putJson($this->baseEndpoint . "/{$chapter->id}", $details);
|
||||||
|
|
|
@ -45,6 +45,7 @@ class PagesApiTest extends TestCase
|
||||||
'value' => 'tagvalue',
|
'value' => 'tagvalue',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'priority' => 15,
|
||||||
];
|
];
|
||||||
|
|
||||||
$resp = $this->postJson($this->baseEndpoint, $details);
|
$resp = $this->postJson($this->baseEndpoint, $details);
|
||||||
|
@ -207,6 +208,7 @@ class PagesApiTest extends TestCase
|
||||||
'value' => 'freshtagval',
|
'value' => 'freshtagval',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'priority' => 15,
|
||||||
];
|
];
|
||||||
|
|
||||||
$resp = $this->putJson($this->baseEndpoint . "/{$page->id}", $details);
|
$resp = $this->putJson($this->baseEndpoint . "/{$page->id}", $details);
|
||||||
|
|
Loading…
Add table
Reference in a new issue