From 3140e527e82d42753d3b699cabd1ae0fc831ac0f Mon Sep 17 00:00:00 2001 From: amazuecos Date: Sun, 2 Mar 2025 10:22:01 +0100 Subject: [PATCH] feat wiki/ayuda section --- ci4/app/Config/Wiki/WikiRoutes.php | 5 +- ci4/app/Controllers/Wiki/WikiController.php | 109 +++++++++++-- ...025-02-22-074400_WikiSectionsMigration.php | 10 +- ...03-02-080000_WikiSectionRolesMigration.php | 60 +++++++ ci4/app/Database/Seeds/WikiSectionSeeder.php | 146 ++++++++++++----- ci4/app/Entities/Wiki/WikiSectionEntity.php | 31 ++++ .../Entities/Wiki/WikiSectionRoleEntity.php | 28 ++++ ci4/app/Language/en/Wiki.php | 41 +++-- ci4/app/Language/es/Wiki.php | 16 ++ ci4/app/Models/Wiki/WikiSectionModel.php | 4 +- ci4/app/Models/Wiki/WikiSectionRoleModel.php | 52 ++++++ .../vuexy/components/modals/modalSection.php | 35 ++-- .../Views/themes/vuexy/main/defaultlayout.php | 1 + .../themes/vuexy/main/menus/wiki_menu.php | 6 +- ci4/app/Views/themes/vuexy/wiki/layout.php | 27 ++- .../Views/themes/vuexy/wiki/pages/render.php | 44 +++-- httpdocs/assets/js/safekat/common/common.js | 32 +++- .../safekat/components/editorjs/WikiEditor.js | 34 ++-- .../components/forms/WikiSectionForm.js | 154 ++++++++++++++---- .../js/safekat/components/listSortable.js | 37 +++++ .../assets/js/safekat/components/modal.js | 1 + httpdocs/assets/js/safekat/pages/wiki/home.js | 3 +- .../js/safekat/pages/wiki/menuSortable.js | 25 +++ .../assets/js/safekat/pages/wiki/viewOnly.js | 2 +- 24 files changed, 735 insertions(+), 168 deletions(-) create mode 100644 ci4/app/Database/Migrations/2025-03-02-080000_WikiSectionRolesMigration.php create mode 100644 ci4/app/Entities/Wiki/WikiSectionRoleEntity.php create mode 100644 ci4/app/Models/Wiki/WikiSectionRoleModel.php create mode 100644 httpdocs/assets/js/safekat/components/listSortable.js create mode 100644 httpdocs/assets/js/safekat/pages/wiki/menuSortable.js diff --git a/ci4/app/Config/Wiki/WikiRoutes.php b/ci4/app/Config/Wiki/WikiRoutes.php index f8cc1384..4c9af9a4 100644 --- a/ci4/app/Config/Wiki/WikiRoutes.php +++ b/ci4/app/Config/Wiki/WikiRoutes.php @@ -7,11 +7,14 @@ $routes->group('wiki', ['namespace' => 'App\Controllers\Wiki'], function ($route $routes->get('','WikiController::index',["as" => "wikiIndex"]); $routes->get('view/(:segment)','WikiController::show_page/$1',["as" => "showWikiPage"]); $routes->get('section/(:num)','WikiController::get_section/$1',["as" => "getWikiSection"]); - $routes->post('section','WikiController::store_section/$1',["as" => "storeWikiSection"]); + $routes->post('section','WikiController::store_section',["as" => "storeWikiSection"]); + $routes->delete('section/(:num)','WikiController::delete_section/$1',["as" => "deleteWikiSection"]); + $routes->post('update/section','WikiController::update_section',["as" => "updateWikiSection"]); $routes->post('save/(:num)','WikiController::store_save_page/$1',["as" => "storeWikiSavePage"]); $routes->post('publish/(:num)','WikiController::store_publish_page/$1',["as" => "storeWikiPublishPage"]); $routes->post('file/upload/(:num)','WikiController::wiki_file_upload/$1',["as" => "storeWikiFileUpload"]); $routes->get('file/(:num)','WikiController::get_wiki_file/$1',["as" => "getWikiFile"]); + $routes->post('section/update/order','WikiController::wiki_section_update_order',["as" => "updateWikiSectionOrder"]); }); \ No newline at end of file diff --git a/ci4/app/Controllers/Wiki/WikiController.php b/ci4/app/Controllers/Wiki/WikiController.php index 1e6b3ee7..8fc93f87 100644 --- a/ci4/app/Controllers/Wiki/WikiController.php +++ b/ci4/app/Controllers/Wiki/WikiController.php @@ -7,10 +7,12 @@ use App\Models\Wiki\WikiContentModel; use App\Models\Wiki\WikiFileModel; use App\Models\Wiki\WikiPageModel; use App\Models\Wiki\WikiSectionModel; +use App\Models\Wiki\WikiSectionRoleModel; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\I18n\Time; use Psr\Log\LoggerInterface; +use Throwable; class WikiController extends BaseController { @@ -18,6 +20,8 @@ class WikiController extends BaseController protected WikiContentModel $wikiContentModel; protected WikiPageModel $wikiPageModel; protected WikiFileModel $wikiFileModel; + protected WikiSectionRoleModel $wikiSectionRoleModel; + protected string $locale; protected array $viewData; @@ -28,6 +32,7 @@ class WikiController extends BaseController $this->wikiPageModel = model(WikiPageModel::class); $this->wikiContentModel = model(WikiContentModel::class); $this->wikiFileModel = model(WikiFileModel::class); + $this->wikiSectionRoleModel = model(WikiSectionRoleModel::class); $sections = $this->wikiSectionModel->sections(); $this->locale = session()->get('lang'); @@ -41,18 +46,32 @@ class WikiController extends BaseController } public function show_page(string $slug) { + $section = $this->wikiSectionModel->where('slug', $slug)->first(); - $this->viewData['slug'] = $slug; - $this->viewData['section'] = $section->withAll($this->locale); - $this->viewData['breadcrumb'] = [ - ['title' => lang("Wiki.".$section->slug), 'route' => route_to('showWikiPage',$slug), 'active' => true], - ]; - return view('themes/vuexy/wiki/pages/render', $this->viewData); + if($section){ + if(auth()->user()->inGroup(...$section->roles_array()) || auth()->user()->inGroup('admin')){ + $this->viewData['slug'] = $slug; + $this->viewData['section'] = $section->withAll($this->locale); + $this->viewData['breadcrumb'] = [ + ['title' => lang("Wiki." . $section->slug), 'route' => route_to('showWikiPage', $slug), 'active' => true], + ]; + return view('themes/vuexy/wiki/pages/render', $this->viewData); + }else{ + return $this->response->setStatusCode(403); + } + }else{ + return redirect_to('/'); + } } public function get_section(int $section_id) { $section = $this->wikiSectionModel->find($section_id)->withAll($this->locale); - return $this->response->setJSON(["data" => $section, "message" => lang("App.global_alert_fetch_success")]); + if(auth()->user()->inGroup(...$section->roles_array()) || auth()->user()->inGroup('admin')){ + + return $this->response->setJSON(["data" => $section, "message" => lang("App.global_alert_fetch_success")]); + }else{ + return $this->response->setStatusCode(403); + } } public function store_save_page(int $section_id) { @@ -82,8 +101,8 @@ class WikiController extends BaseController $wikiSectionPage = $this->wikiSectionModel->find($section_id)->page(); if ($wikiSectionPage) { $wikiPageId = $wikiSectionPage->id; - $wikiContentId = $this->wikiContentModel->where("page_id",$wikiPageId)->where('locale',$this->locale)->first()->id; - $this->wikiContentModel->update($wikiContentId,[ + $wikiContentId = $this->wikiContentModel->where("page_id", $wikiPageId)->where('locale', $this->locale)->first()->id; + $this->wikiContentModel->update($wikiContentId, [ "published_by" => auth()->user()->id, "last_edit_by" => auth()->user()->id, "editor_data" => json_encode($bodyData), @@ -109,16 +128,16 @@ class WikiController extends BaseController $fullpath = $file->store('wiki_images/' . $section->slug); $r = $this->wikiFileModel->insert(["content_id" => $content->id, "path" => $fullpath]); return $this->response->setJSON(["success" => 1, "file" => [ - "url" => '/wiki/file/'.$r + "url" => '/wiki/file/' . $r ]]); - }else{ + } else { return $this->response->setJSON(["success" => 0, "file" => [ "url" => null ]]); } } catch (\Throwable $th) { - - return $this->response->setJSON(["success" => 0, "error" => $th->getMessage()])->setStatusCode($th->getCode()); + + return $this->response->setJSON(["success" => 0, "error" => $th->getMessage()])->setStatusCode(403); } } public function get_wiki_file(int $wiki_file_id) @@ -132,7 +151,69 @@ class WikiController extends BaseController ->setHeader('Content-Length', filesize($filePath)) ->setBody(file_get_contents($filePath)); } else { - return $this->response->setJSON(["message" => "Portada error", "error" => "No hay portada"])->setStatusCode(400); + return $this->response->setJSON(["success" => 0, "error" => lang('Wiki.file_dont_exist')])->setStatusCode(400); + } + } + public function wiki_section_update_order() + { + try { + $bodyData = $this->request->getPost(); + $orders = $bodyData['orders']; + foreach ($orders as $key => $section_id) { + $this->wikiSectionModel->update($section_id, ['order' => $key]); + } + return $this->response->setJSON(["status" => 1, "message" => lang('Wiki.order_success')]); + } catch (\Throwable $th) { + return $this->response->setJSON(["status" => 0, "message" => lang('Wiki.order_error')])->setStatusCode(400); + } + } + public function store_section() + { + try { + $bodyData = $this->request->getPost(); + $sectionName = $bodyData['name']; + $roles = $bodyData['roles']; + $bodyData["slug"] = implode('-', array_map(fn($e) => strtolower($e), explode(' ', $sectionName))); + $bodyData["order"] = $this->wikiSectionModel->selectMax('order')->first()->order + 1; + $wikiSectionId = $this->wikiSectionModel->insert($bodyData); + if(count($roles) > 0){ + foreach ($roles as $key => $role) { + $this->wikiSectionRoleModel->insert(['wiki_section_id' => $wikiSectionId , 'role' => $role]); + } + } + return $this->response->setJSON(["status" => 1, "message" => lang('Wiki.section_new_success')]); + } catch (\Throwable $th) { + return $this->response->setJSON(["status" => 0, "message" => $th->getMessage()])->setStatusCode(400); + } + } + public function update_section() + { + try { + $bodyData = $this->request->getPost(); + $wikiSectionId = $bodyData['wiki_section_id']; + $roles = $bodyData['roles']; + $this->wikiSectionModel->update($wikiSectionId, [ + "name" => $bodyData['name'], + "icon" => $bodyData['icon'] + ]); + $this->wikiSectionRoleModel->where('wiki_section_id',$wikiSectionId)->delete(); + if(count($roles) > 0){ + foreach ($roles as $key => $role) { + $this->wikiSectionRoleModel->insert(['wiki_section_id' => $wikiSectionId , 'role' => $role]); + } + } + return $this->response->setJSON(["status" => 1, "message" => lang('Wiki.section_edit_success')]); + } catch (\Throwable $th) { + return $this->response->setJSON(["status" => 0, "message" => $th->getMessage()])->setStatusCode(400); + } + } + public function delete_section(int $section_id) + { + try{ + $this->wikiSectionModel->delete($section_id); + return $this->response->setJSON(["status" => 1, "message" => lang('Wiki.section_delete_success')]); + }catch(Throwable $th){ + return $this->response->setJSON(["status" => 0, "message" => $th->getMessage()])->setStatusCode(400); } } } diff --git a/ci4/app/Database/Migrations/2025-02-22-074400_WikiSectionsMigration.php b/ci4/app/Database/Migrations/2025-02-22-074400_WikiSectionsMigration.php index b450d8f1..dfd31d14 100644 --- a/ci4/app/Database/Migrations/2025-02-22-074400_WikiSectionsMigration.php +++ b/ci4/app/Database/Migrations/2025-02-22-074400_WikiSectionsMigration.php @@ -14,6 +14,11 @@ class WikiSectionsMigration extends Migration 'unsigned' => true, 'auto_increment' => true, ], + 'order' => [ + 'type' => 'INT', + 'unsigned' => true, + 'null'=> true, + ], 'name' => [ 'type' => 'VARCHAR', 'constraint' => 255, @@ -22,11 +27,6 @@ class WikiSectionsMigration extends Migration 'type' => 'VARCHAR', 'constraint' => 255, ], - 'role' => [ - 'type' => 'VARCHAR', - 'constraint' => 255, - 'default' => 'admin' - ], 'icon' => [ 'type' => 'VARCHAR', 'constraint' => 255, diff --git a/ci4/app/Database/Migrations/2025-03-02-080000_WikiSectionRolesMigration.php b/ci4/app/Database/Migrations/2025-03-02-080000_WikiSectionRolesMigration.php new file mode 100644 index 00000000..4f6e63e6 --- /dev/null +++ b/ci4/app/Database/Migrations/2025-03-02-080000_WikiSectionRolesMigration.php @@ -0,0 +1,60 @@ + [ + 'type' => 'INT', + 'unsigned' => true, + 'auto_increment' => true, + ], + 'wiki_section_id' => [ + 'type' => 'INT', + 'unsigned' => true, + ], + 'role' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + 'default' => 'admin' + ], + + + ]; + + public function up() + { + $this->forge->addField($this->COLUMNS); + $currenttime = new RawSql('CURRENT_TIMESTAMP'); + $this->forge->addField([ + 'created_at' => [ + 'type' => 'TIMESTAMP', + 'default' => $currenttime, + + ], + 'updated_at' => [ + 'type' => 'TIMESTAMP', + 'null' => true, + + ], + 'deleted_at' => [ + 'type' => 'TIMESTAMP', + 'null' => true, + + ], + ]); + $this->forge->addPrimaryKey('id'); + $this->forge->addForeignKey('wiki_section_id','wiki_sections','id'); + $this->forge->createTable("wiki_section_roles"); + } + + public function down() + { + $this->forge->dropTable("wiki_section_roles"); + } +} diff --git a/ci4/app/Database/Seeds/WikiSectionSeeder.php b/ci4/app/Database/Seeds/WikiSectionSeeder.php index 3f2b28f3..0b433a8e 100644 --- a/ci4/app/Database/Seeds/WikiSectionSeeder.php +++ b/ci4/app/Database/Seeds/WikiSectionSeeder.php @@ -4,102 +4,162 @@ namespace App\Database\Seeds; use App\Models\Configuracion\ConfigVariableModel; use App\Models\Wiki\WikiSectionModel; +use App\Models\Wiki\WikiSectionRoleModel; use CodeIgniter\Database\Seeder; class WikiSectionSeeder extends Seeder { protected array $dataAdmin = [ - [ - "name" => 'Introducción', - "slug" => 'intro-admin', - "icon" => 'ti ti-home-2' + [ + "name" => 'Introducción', + "slug" => 'intro-admin', + "icon" => 'ti ti-home-2', + "roles" => [ + "admin", ], - [ - "name" => 'Presupuesto', - "slug" => 'presupuesto-admin', - "icon" => 'ti ti-currency-dollar' + ], + [ + "name" => 'Presupuesto', + "slug" => 'presupuesto-admin', + "icon" => 'ti ti-currency-dollar', + "roles" => [ + "admin", + ], + ], + [ + "name" => 'Pedidos', + "slug" => 'pedidos-admin', + "icon" => 'ti ti-file-description', + "roles" => [ + "admin", ], - [ - "name" => 'Pedidos', - "slug" => 'pedidos-admin', - "icon" => 'ti ti-file-description' + ], + [ + "name" => 'Facturación', + "slug" => 'facturacion-admin', + "icon" => 'ti ti-file-dollar', + "roles" => [ + "admin", ], - [ - "name" => 'Facturación', - "slug" => 'facturacion-admin', - "icon" => 'ti ti-file-dollar' + ], + [ + "name" => 'Logística', + "slug" => 'logistica-admin', + "icon" => 'ti ti-truck', + "roles" => [ + "admin", ], - [ - "name" => 'Logística', - "slug" => 'logistica-admin', - "icon" => 'ti ti-truck' + ], + [ + "name" => 'Tarifas', + "slug" => 'tarifas-admin', + "icon" => 'ti ti-receipt', + "roles" => [ + "admin", ], - [ - "name" => 'Tarifas', - "slug" => 'tarifas-admin', - "icon" => 'ti ti-receipt' + ], + [ + "name" => 'Configuración', + "slug" => 'config-admin', + "icon" => 'ti ti-adjustments-horizontal', + "roles" => [ + "admin", ], - [ - "name" => 'Configuración', - "slug" => 'config-admin', - "icon" => 'ti ti-adjustments-horizontal' + ], + [ + "name" => 'Mensajería', + "slug" => 'messages-admin', + "icon" => 'ti ti-message', + "roles" => [ + "admin", ], - [ - "name" => 'Mensajería', - "slug" => 'messages-admin', - "icon" => 'ti ti-message' - ] + ] ]; protected array $dataCliente = [ + [ + "name" => 'Introducción', + "slug" => 'intro-cliente', + "icon" => 'ti ti-home-2', + "roles" => [ + "cliente-admin", + "cliente-editor", + ] + ], [ "name" => 'Presupuesto(Cliente)', "slug" => 'presupuesto-cliente', "role" => 'cliente', "icon" => 'ti ti-currency-dollar', - "role" => 'cliente', + "roles" => [ + "cliente-admin", + "cliente-editor", + ] ], [ "name" => 'Pedidos(Cliente)', "slug" => 'pedidos-cliente', "icon" => 'ti ti-file-description', - "role" => 'cliente', + "roles" => [ + "cliente-admin", + "cliente-editor", + ] ], [ "name" => 'Facturación (Cliente)', "slug" => 'facturacion-cliente', "icon" => 'ti ti-file-dollar', - "role" => 'cliente', + "roles" => [ + "cliente-admin", + "cliente-editor", + ] ], [ "name" => 'Tarifas (Cliente)', "slug" => 'tarifas-cliente', "icon" => 'ti ti-receipt', - "role" => 'cliente', + "roles" => [ + "cliente-admin", + "cliente-editor", + ] ], [ "name" => 'Mensajería (Cliente)', "slug" => 'messages-cliente', "icon" => 'ti ti-message', - "role" => 'cliente', + "roles" => [ + "cliente-admin", + "cliente-editor", + ] ] -]; + ]; public function run() { $wikiSectionModel = model(WikiSectionModel::class); + $wikiSectionRoleModel = model(WikiSectionRoleModel::class); + $section_order = 0; foreach ($this->dataAdmin as $key => $row) { - # code... - $wikiSectionModel->insert($row); + $row['order'] = $section_order; + $wikiSectionId = $wikiSectionModel->insert($row); + $section_order++; + foreach ($row['roles'] as $key => $role) { + $wikiSectionRoleModel->insert(['wiki_section_id' => $wikiSectionId,"role" => $role]); + + } } foreach ($this->dataCliente as $key => $row) { - # code... - $wikiSectionModel->insert($row); + $row['order'] = $section_order; + $wikiSectionId = $wikiSectionModel->insert($row); + $section_order++; + foreach ($row['roles'] as $key => $role) { + $wikiSectionRoleModel->insert(['wiki_section_id' => $wikiSectionId,"role" => $role]); + } } } } diff --git a/ci4/app/Entities/Wiki/WikiSectionEntity.php b/ci4/app/Entities/Wiki/WikiSectionEntity.php index af77e526..160b42f4 100644 --- a/ci4/app/Entities/Wiki/WikiSectionEntity.php +++ b/ci4/app/Entities/Wiki/WikiSectionEntity.php @@ -3,6 +3,7 @@ namespace App\Entities\Wiki; use App\Models\Wiki\WikiContentModel; use App\Models\Wiki\WikiPageModel; +use App\Models\Wiki\WikiSectionRoleModel; use CodeIgniter\Entity\Entity; class WikiSectionEntity extends Entity @@ -11,6 +12,7 @@ class WikiSectionEntity extends Entity "name" => null, "slug" => null, "role" => null, + "order" => null, "icon" => null, "parent_id" => null ]; @@ -19,6 +21,7 @@ class WikiSectionEntity extends Entity "slug" => "string", "role" => "string", "icon" => "string", + "order" => "int", "parent_id" => "int" ]; @@ -34,10 +37,25 @@ class WikiSectionEntity extends Entity $this->attributes['contents'] = $this->content($locale); return $this; } + public function withRoles(): self + { + $m = model(WikiSectionRoleModel::class); + $this->attributes['roles'] = $this->roles(); + return $this; + } + public function withRolesArray(): self + { + $m = model(WikiSectionRoleModel::class); + $this->attributes['roles_array'] = $this->roles_array(); + return $this; + } public function withAll(string $locale = "es") : self { $this->withPage(); $this->withContents($locale); + $this->withRoles(); + $this->withRolesArray(); + return $this; } @@ -46,6 +64,19 @@ class WikiSectionEntity extends Entity $m = model(WikiPageModel::class); return $m->where('section_id',$this->attributes['id'])->first(); } + public function roles_array(): ?array + { + $m = model(WikiSectionRoleModel::class); + $section_roles = $m->where('wiki_section_id',$this->attributes['id'])->findAll(); + $roles = array_map(fn($r) => $r->role,$section_roles); + return $roles; + } + public function roles(): ?array + { + $m = model(WikiSectionRoleModel::class); + $section_roles = $m->where('wiki_section_id',$this->attributes['id'])->findAll(); + return $section_roles; + } public function content(string $locale = "es"): ?WikiContentEntity { $page = $this->page(); diff --git a/ci4/app/Entities/Wiki/WikiSectionRoleEntity.php b/ci4/app/Entities/Wiki/WikiSectionRoleEntity.php new file mode 100644 index 00000000..bde02da8 --- /dev/null +++ b/ci4/app/Entities/Wiki/WikiSectionRoleEntity.php @@ -0,0 +1,28 @@ + null, + "role" => null, + ]; + protected $casts = [ + "wiki_section_id" => "int", + "role" => "string", + ]; + + public function page(): ?WikiSectionEntity + { + $m = model(WikiSectionModel::class); + return $m->where('id',$this->attributes['section_id'])->first(); + } + + + +} diff --git a/ci4/app/Language/en/Wiki.php b/ci4/app/Language/en/Wiki.php index e380ee1f..553cbf9d 100644 --- a/ci4/app/Language/en/Wiki.php +++ b/ci4/app/Language/en/Wiki.php @@ -1,23 +1,44 @@ "Introduction", - 'presupuesto-cliente' => "Cliente budget", - 'presupuesto-administrador' => "Admin budget", - 'pedidos' => "Orders", - 'facturacion' => "Invoice", - 'logistica' => "Logistic", - 'tarifas' => "Tariff", - 'config' => "Configuration", - 'messages' => "Messages", + 'help' => "Help", + 'intro-admin' => "Introduction", + 'presupuesto-cliente' => "Client budget", + 'presupuesto-admin' => "Admin budget", + 'pedidos-cliente' => "Orders", + 'pedidos-admin' => "Orders", + 'facturacion-admin' => "Invoice", + 'facturacion-cliente' => "Invoice (Client)", + 'logistica-admin' => "Logistic", + 'tarifas-admin' => "Tariff", + 'tarifas-cliente' => "Tariff (Client)", + 'config-admin' => "Configuration", + 'messages-admin' => "Messages", + 'messages-cliente' => "Messages (Client)", 'save' => "Save", 'release' => "Release", 'preview' => "Preview", 'edit' => "Edit", 'new_section' => "New section", + 'edit_section' => "Edit section", + 'header-placeholder' => "Start writing a header ...", 'errors' => [ 'publish_before_save' => "You have to save before publish the content" ], + 'alt' => [ + "sort" => "Drag to set the section order" + ], + 'order_success' => 'Order updated', + 'order_error' => 'An error has ocurred', 'published' => 'Released', - 'not_published' => 'Not released' + 'not_published' => 'Not released', + 'section_new_success' => 'Section created successfully', + 'section_edit_success' => 'Section updated successfully', + 'need_reload' => 'You need to refresh the page after creating/updating a section to see the changes.', + 'file_dont_exist' => "File doesn't exist", + 'need_editor_to_save' => 'Need to be in edit mode to save the content.', + 'no_content' => 'Page is empty', + 'dropdown_roles' => 'Roles that can see this section', + + ]; \ No newline at end of file diff --git a/ci4/app/Language/es/Wiki.php b/ci4/app/Language/es/Wiki.php index 6b72e03c..b5040849 100644 --- a/ci4/app/Language/es/Wiki.php +++ b/ci4/app/Language/es/Wiki.php @@ -1,6 +1,7 @@ "Ayuda", 'intro-admin' => "Introducción", 'intro-cliente' => "Introducción", 'presupuesto-cliente' => "Presupuesto (Cliente)", @@ -22,6 +23,7 @@ return [ 'name' => "Nombre sección", 'icon' => "Icono sección", 'section_placeholder' => "Introduce el nombre de la sección", + 'section_order' => "Orden", 'section_icon_placeholder' => "Introduce el nombre de la sección", 'edit_section' => "Editar sección", 'new_section' => "Nueva sección", @@ -29,6 +31,20 @@ return [ 'errors' => [ 'publish_before_save' => "Es necesario guardar antes de publicar" ], + 'alt' => [ + "sort" => "Arrastra para establecer el orden de la sección" + ], + 'order_success' => 'Orden actualizado correctamente', + 'order_error' => 'Ha ocurriendo un error al ordenar', 'published' => 'Publicado', 'not_published' => 'Sin publicar', + 'section_new_success' => 'Sección creada correctamente', + 'section_edit_success' => 'Sección actualizada correctamente', + 'need_reload' => 'Es necesario recargar la página para ver la nueva sección creada o editada.', + 'file_dont_exist' => 'El fichero no existe', + 'need_editor_to_save' => 'Tienes que estar en modo editar para guardar.', + 'no_content' => 'No hay contenido en la página', + 'dropdown_roles' => 'Roles que pueden ver la sección', + + ]; diff --git a/ci4/app/Models/Wiki/WikiSectionModel.php b/ci4/app/Models/Wiki/WikiSectionModel.php index 7a240278..12885766 100644 --- a/ci4/app/Models/Wiki/WikiSectionModel.php +++ b/ci4/app/Models/Wiki/WikiSectionModel.php @@ -16,8 +16,8 @@ class WikiSectionModel extends Model protected $allowedFields = [ "name", "slug", - "role", "icon", + "order", "parent_id" ]; @@ -58,6 +58,6 @@ class WikiSectionModel extends Model */ public function sections() : array { - return $this->findAll(); + return $this->orderBy('order','asc')->findAll(); } } diff --git a/ci4/app/Models/Wiki/WikiSectionRoleModel.php b/ci4/app/Models/Wiki/WikiSectionRoleModel.php new file mode 100644 index 00000000..070a7ddd --- /dev/null +++ b/ci4/app/Models/Wiki/WikiSectionRoleModel.php @@ -0,0 +1,52 @@ + diff --git a/ci4/app/Views/themes/vuexy/main/defaultlayout.php b/ci4/app/Views/themes/vuexy/main/defaultlayout.php index 847fbab9..adc7e9e1 100644 --- a/ci4/app/Views/themes/vuexy/main/defaultlayout.php +++ b/ci4/app/Views/themes/vuexy/main/defaultlayout.php @@ -346,6 +346,7 @@ $picture = "/assets/img/default-user.png"; + diff --git a/ci4/app/Views/themes/vuexy/main/menus/wiki_menu.php b/ci4/app/Views/themes/vuexy/main/menus/wiki_menu.php index d16a5a8c..56b5e1cf 100644 --- a/ci4/app/Views/themes/vuexy/main/menus/wiki_menu.php +++ b/ci4/app/Views/themes/vuexy/main/menus/wiki_menu.php @@ -4,13 +4,13 @@ user()->inGroup('admin')):?> - + user()->inGroup('cliente-editor')):?> - + - + \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/wiki/layout.php b/ci4/app/Views/themes/vuexy/wiki/layout.php index f36ef1a1..7d582df1 100644 --- a/ci4/app/Views/themes/vuexy/wiki/layout.php +++ b/ci4/app/Views/themes/vuexy/wiki/layout.php @@ -105,17 +105,25 @@ $picture = "/assets/img/default-user.png"; -