1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Renamed attribute to tags & continued interface

Also fixed page create route broken in last commit
This commit is contained in:
Dan Brown
2016-05-13 21:20:21 +01:00
parent 1fa079b466
commit b80184cd93
18 changed files with 369 additions and 282 deletions

View File

@ -1,64 +0,0 @@
<?php namespace BookStack\Http\Controllers;
use BookStack\Repos\AttributeRepo;
use Illuminate\Http\Request;
use BookStack\Http\Requests;
class AttributeController extends Controller
{
protected $attributeRepo;
/**
* AttributeController constructor.
* @param $attributeRepo
*/
public function __construct(AttributeRepo $attributeRepo)
{
$this->attributeRepo = $attributeRepo;
}
/**
* Get all the Attributes for a particular entity
* @param $entityType
* @param $entityId
*/
public function getForEntity($entityType, $entityId)
{
$attributes = $this->attributeRepo->getForEntity($entityType, $entityId);
return response()->json($attributes);
}
/**
* Update the attributes for a particular entity.
* @param $entityType
* @param $entityId
* @param Request $request
* @return mixed
*/
public function updateForEntity($entityType, $entityId, Request $request)
{
$entity = $this->attributeRepo->getEntity($entityType, $entityId, 'update');
if ($entity === null) return $this->jsonError("Entity not found", 404);
$inputAttributes = $request->input('attributes');
$attributes = $this->attributeRepo->saveAttributesToEntity($entity, $inputAttributes);
return response()->json([
'attributes' => $attributes,
'message' => 'Attributes successfully updated'
]);
}
/**
* Get attribute name suggestions from a given search term.
* @param Request $request
*/
public function getNameSuggestions(Request $request)
{
$searchTerm = $request->get('search');
$suggestions = $this->attributeRepo->getNameSuggestions($searchTerm);
return response()->json($suggestions);
}
}

View File

@ -0,0 +1,64 @@
<?php namespace BookStack\Http\Controllers;
use BookStack\Repos\TagRepo;
use Illuminate\Http\Request;
use BookStack\Http\Requests;
class TagController extends Controller
{
protected $tagRepo;
/**
* TagController constructor.
* @param $tagRepo
*/
public function __construct(TagRepo $tagRepo)
{
$this->tagRepo = $tagRepo;
}
/**
* Get all the Tags for a particular entity
* @param $entityType
* @param $entityId
*/
public function getForEntity($entityType, $entityId)
{
$tags = $this->tagRepo->getForEntity($entityType, $entityId);
return response()->json($tags);
}
/**
* Update the tags for a particular entity.
* @param $entityType
* @param $entityId
* @param Request $request
* @return mixed
*/
public function updateForEntity($entityType, $entityId, Request $request)
{
$entity = $this->tagRepo->getEntity($entityType, $entityId, 'update');
if ($entity === null) return $this->jsonError("Entity not found", 404);
$inputTags = $request->input('tags');
$tags = $this->tagRepo->saveTagsToEntity($entity, $inputTags);
return response()->json([
'tags' => $tags,
'message' => 'Tags successfully updated'
]);
}
/**
* Get tag name suggestions from a given search term.
* @param Request $request
*/
public function getNameSuggestions(Request $request)
{
$searchTerm = $request->get('search');
$suggestions = $this->tagRepo->getNameSuggestions($searchTerm);
return response()->json($suggestions);
}
}