From f6d3d3c697eb1765a1352b5a46c07e850a747a55 Mon Sep 17 00:00:00 2001 From: vikram chand Date: Thu, 18 Feb 2021 18:06:12 +0530 Subject: [PATCH 01/21] Updated submodule Vue/vaahvue --- Vue/vaahvue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vue/vaahvue b/Vue/vaahvue index 5d77880..70a2068 160000 --- a/Vue/vaahvue +++ b/Vue/vaahvue @@ -1 +1 @@ -Subproject commit 5d77880a904e694a6c272eb234fdcd6f01c50c7c +Subproject commit 70a206801477d723a17b1f77eeac81f567244918 From dd8d66781980fc75254993a1e7c9298beac3cfd9 Mon Sep 17 00:00:00 2001 From: vikram chand Date: Fri, 19 Feb 2021 14:02:11 +0530 Subject: [PATCH 02/21] Fixed: Form Group --- Entities/FormGroup.php | 5 +++++ Libraries/CmsSeeder.php | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Entities/FormGroup.php b/Entities/FormGroup.php index 64cbc53..d48eb32 100644 --- a/Entities/FormGroup.php +++ b/Entities/FormGroup.php @@ -173,6 +173,11 @@ public static function syncWithFormFields(FormGroup $group, $fields_array) foreach ($fields_array as $f_index => $field) { + if(!isset($field['slug']) || !$field['slug']){ + $field['slug'] = Str::slug($field['name']); + } + + $stored_field = FormField::where('vh_cms_form_group_id', $group->id) ->where('slug', $field['slug']) ->first(); diff --git a/Libraries/CmsSeeder.php b/Libraries/CmsSeeder.php index 611c14c..5f22b97 100644 --- a/Libraries/CmsSeeder.php +++ b/Libraries/CmsSeeder.php @@ -163,6 +163,8 @@ public static function templates($theme_slug, $file_path) ->where('slug', $template['template']['slug']) ->first(); + $stored_template = ThemeTemplate::find($stored_template->id); + //template groups ThemeTemplate::syncWithFormGroups($stored_template, $template['groups']); @@ -187,9 +189,9 @@ public static function contentTypes($file_path) if(!$exist) { - $stored = DB::table('vh_cms_content_types')->insert($content_type['content']); + DB::table('vh_cms_content_types')->insert($content_type['content']); } else{ - $stored = DB::table('vh_cms_content_types') + DB::table('vh_cms_content_types') ->where('slug', $content_type['content']['slug']) ->update($content_type['content']); } From 24591d64f1549c6564ab41022906b15bf433d599 Mon Sep 17 00:00:00 2001 From: vikram chand Date: Fri, 19 Feb 2021 14:29:52 +0530 Subject: [PATCH 03/21] Added: block vue components, vue routes --- Http/Controllers/Backend/BlocksController.php | 137 +++++++ Http/Controllers/Backend/JsonController.php | 7 + Routes/backend.php | 1 + Routes/backend/blocks.php | 40 ++ Vue/pages/blocks/ContentStructure.vue | 302 +++++++++++++++ Vue/pages/blocks/ContentStructureJs.js | 226 +++++++++++ Vue/pages/blocks/Create.vue | 175 +++++++++ Vue/pages/blocks/CreateJs.js | 227 +++++++++++ Vue/pages/blocks/Edit.vue | 201 ++++++++++ Vue/pages/blocks/EditJs.js | 217 +++++++++++ Vue/pages/blocks/List.vue | 332 ++++++++++++++++ Vue/pages/blocks/ListJs.js | 354 ++++++++++++++++++ Vue/pages/blocks/View.vue | 176 +++++++++ Vue/pages/blocks/ViewJs.js | 210 +++++++++++ Vue/pages/blocks/partials/ListLargeView.vue | 118 ++++++ Vue/pages/blocks/partials/ListLargeViewJs.js | 113 ++++++ Vue/pages/blocks/partials/ListMediumView.vue | 119 ++++++ Vue/pages/blocks/partials/ListMediumViewJs.js | 113 ++++++ Vue/pages/blocks/partials/ListSmallView.vue | 56 +++ Vue/pages/blocks/partials/ListSmallViewJs.js | 113 ++++++ Vue/routes/routes.js | 81 ++++ Vue/store/modules/blocks.js | 141 +++++++ Vue/store/store.js | 2 + 23 files changed, 3461 insertions(+) create mode 100644 Http/Controllers/Backend/BlocksController.php create mode 100644 Routes/backend/blocks.php create mode 100644 Vue/pages/blocks/ContentStructure.vue create mode 100644 Vue/pages/blocks/ContentStructureJs.js create mode 100644 Vue/pages/blocks/Create.vue create mode 100644 Vue/pages/blocks/CreateJs.js create mode 100644 Vue/pages/blocks/Edit.vue create mode 100644 Vue/pages/blocks/EditJs.js create mode 100644 Vue/pages/blocks/List.vue create mode 100644 Vue/pages/blocks/ListJs.js create mode 100644 Vue/pages/blocks/View.vue create mode 100644 Vue/pages/blocks/ViewJs.js create mode 100644 Vue/pages/blocks/partials/ListLargeView.vue create mode 100644 Vue/pages/blocks/partials/ListLargeViewJs.js create mode 100644 Vue/pages/blocks/partials/ListMediumView.vue create mode 100644 Vue/pages/blocks/partials/ListMediumViewJs.js create mode 100644 Vue/pages/blocks/partials/ListSmallView.vue create mode 100644 Vue/pages/blocks/partials/ListSmallViewJs.js create mode 100644 Vue/store/modules/blocks.js diff --git a/Http/Controllers/Backend/BlocksController.php b/Http/Controllers/Backend/BlocksController.php new file mode 100644 index 0000000..2fed719 --- /dev/null +++ b/Http/Controllers/Backend/BlocksController.php @@ -0,0 +1,137 @@ +theme = vh_get_backend_theme(); + } + + public function getAssets(Request $request) + { + + $data['field_types'] = FieldType::select('id', 'name', 'slug', 'meta') + ->get(); + + $data['bulk_actions'] = vh_general_bulk_actions(); + + $response['status'] = 'success'; + $response['data'] = $data; + + return response()->json($response); + } + //---------------------------------------------------------- + public function postCreate(Request $request) + { + $response = ContentType::postCreate($request); + return response()->json($response); + } + //---------------------------------------------------------- + public function getList(Request $request) + { + $response = ContentType::getList($request); + return response()->json($response); + } + //---------------------------------------------------------- + public function getItem(Request $request, $id) + { + + $response = ContentType::getItem($id); + return response()->json($response); + + } + //---------------------------------------------------------- + public function getItemRelations(Request $request, $id) + { + + $response = ContentType::getItemWithRelations($id); + return response()->json($response); + + } + //---------------------------------------------------------- + public function postStoreGroups(Request $request, $id) + { + $response = ContentType::postStoreGroups($request, $id); + return response()->json($response); + } + //---------------------------------------------------------- + public function postStore(Request $request,$id) + { + $response = ContentType::postStore($request,$id); + return response()->json($response); + } + + //---------------------------------------------------------- + //---------------------------------------------------------- + public function postActions(Request $request, $action) + { + $rules = array( + 'inputs' => 'required', + ); + + $validator = \Validator::make( $request->all(), $rules); + if ( $validator->fails() ) { + + $errors = errorsToArray($validator->errors()); + $response['status'] = 'failed'; + $response['errors'] = $errors; + return response()->json($response); + } + + $response = []; + + $response['status'] = 'success'; + + $inputs = $request->all(); + + switch ($action) + { + + //------------------------------------ + case 'bulk-change-status': + $response = ContentType::bulkStatusChange($request); + break; + //------------------------------------ + case 'bulk-trash': + + $response = ContentType::bulkTrash($request); + + break; + //------------------------------------ + case 'bulk-restore': + + $response = ContentType::bulkRestore($request); + + break; + + //------------------------------------ + case 'bulk-delete': + + $response = ContentType::bulkDelete($request); + + break; + + //------------------------------------ + } + + return response()->json($response); + + } + + //---------------------------------------------------------- + //---------------------------------------------------------- + //---------------------------------------------------------- + + +} diff --git a/Http/Controllers/Backend/JsonController.php b/Http/Controllers/Backend/JsonController.php index c16838a..8fc428e 100644 --- a/Http/Controllers/Backend/JsonController.php +++ b/Http/Controllers/Backend/JsonController.php @@ -52,6 +52,13 @@ public function getAssets(Request $request) 'path' => "/menus", ], + [ + "label"=>'Blocks', + "icon"=>'link', + "link"=> self::$link."blocks", + 'path' => "/blocks", + ], + ], ]; diff --git a/Routes/backend.php b/Routes/backend.php index ae06032..b192dea 100644 --- a/Routes/backend.php +++ b/Routes/backend.php @@ -43,5 +43,6 @@ function () { ->name( 'vh.backend.cms.getUserById' ); include('backend/content-types.php'); +include('backend/blocks.php'); include('backend/contents.php'); include('backend/menus.php'); diff --git a/Routes/backend/blocks.php b/Routes/backend/blocks.php new file mode 100644 index 0000000..445dd48 --- /dev/null +++ b/Routes/backend/blocks.php @@ -0,0 +1,40 @@ + 'backend/cms/blocks', + 'namespace' => 'Backend', + 'middleware' => ['web', 'has.backend.access'], + ], + function () { + //--------------------------------------------------------- + Route::get('/assets', 'BlocksController@getAssets') + ->name('backend.cms.blocks.assets'); + //--------------------------------------------------------- + Route::post('/create', 'BlocksController@postCreate') + ->name('backend.cms.blocks.create'); + //--------------------------------------------------------- + Route::get('/list', 'BlocksController@getList') + ->name('backend.cms.blocks.list'); + //--------------------------------------------------------- + Route::get('/item/{id}', 'BlocksController@getItem') + ->name('backend.cms.blocks.item'); + //--------------------------------------------------------- + Route::post('/item/{id}/relations', 'BlocksController@getItemRelations') + ->name('backend.cms.blocks.item.relations'); + //--------------------------------------------------------- + Route::post('/store/{id}', 'BlocksController@postStore') + ->name('backend.cms.blocks.store'); + //--------------------------------------------------------- + Route::post('/store/{id}/groups', 'BlocksController@postStoreGroups') + ->name('backend.cms.blocks.store.groups'); + //--------------------------------------------------------- + Route::post('/actions/{action_name}', 'BlocksController@postActions') + ->name('backend.cms.blocks.actions'); + //--------------------------------------------------------- + Route::get('/getModuleSections', 'BlocksController@getModuleSections') + ->name('backend.cms.blocks.module-section'); + //--------------------------------------------------------- + }); diff --git a/Vue/pages/blocks/ContentStructure.vue b/Vue/pages/blocks/ContentStructure.vue new file mode 100644 index 0000000..9e4f23a --- /dev/null +++ b/Vue/pages/blocks/ContentStructure.vue @@ -0,0 +1,302 @@ + + diff --git a/Vue/pages/blocks/ContentStructureJs.js b/Vue/pages/blocks/ContentStructureJs.js new file mode 100644 index 0000000..3b61e29 --- /dev/null +++ b/Vue/pages/blocks/ContentStructureJs.js @@ -0,0 +1,226 @@ +import GlobalComponents from '../../vaahvue/helpers/GlobalComponents' +import draggable from 'vuedraggable'; + +let namespace = 'blocks'; + +export default { + props: ['id'], + computed:{ + root() {return this.$store.getters['root/state']}, + page() {return this.$store.getters[namespace+'/state']}, + assets() {return this.$store.getters[namespace+'/state'].assets}, + ajax_url() {return this.$store.getters[namespace+'/state'].ajax_url}, + item() {return this.$store.getters[namespace+'/state'].active_item}, + }, + components:{ + ...GlobalComponents, + draggable, + + }, + data() + { + return { + namespace: namespace, + is_content_loading: false, + is_btn_loading: null, + labelPosition: 'on-border', + params: {}, + local_action: null, + new_group:{ + name:null, + fields:[ + ] + }, + + + } + }, + watch: { + $route(to, from) { + this.updateView(); + this.getItem(); + }, + + + }, + mounted() { + //---------------------------------------------------- + + //---------------------------------------------------- + this.onLoad(); + //---------------------------------------------------- + + //---------------------------------------------------- + }, + methods: { + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + update: function(name, value) + { + let update = { + state_name: name, + state_value: value, + namespace: this.namespace, + }; + this.$vaah.updateState(update); + }, + //--------------------------------------------------------------------- + updateItem: function() + { + let update = { + state_name: 'active_item', + state_value: this.item, + namespace: this.namespace, + }; + this.$vaah.updateState(update); + }, + //--------------------------------------------------------------------- + updateView: function() + { + this.$store.dispatch(this.namespace+'/updateView', this.$route); + }, + //--------------------------------------------------------------------- + onLoad: function() + { + this.is_content_loading = true; + this.updateView(); + this.getAssets(); + }, + //--------------------------------------------------------------------- + async getAssets() { + await this.$store.dispatch(namespace+'/getAssets'); + this.getItem(); + }, + + //--------------------------------------------------------------------- + getItem: function () { + this.$Progress.start(); + let params = {}; + let url = this.ajax_url+'/item/'+this.$route.params.id+'/relations'; + this.$vaah.ajax(url, params, this.getItemAfter); + }, + //--------------------------------------------------------------------- + getItemAfter: function (data, res) { + this.$Progress.finish(); + if(data){ + + if(data.groups.length == 0){ + data.groups[0] = { + 'name' : 'Default', + 'slug' : 'default', + 'fields' : [], + }; + } + + this.update('active_item', data); + } + + }, + //--------------------------------------------------------------------- + addNewGroup: function () { + if(this.new_group.name){ + if(this.new_group.name.length > 100){ + this.$vaah.toastErrors(['Group may not be greater than 100 characters.']); + }else{ + this.item.groups.push(this.new_group); + this.update('item', this.item); + this.resetNewGroup(); + } + }else{ + this.$vaah.toastErrors(['Group Field is required.']); + } + }, + //--------------------------------------------------------------------- + resetNewGroup: function () { + + this.new_group = { + name: null, + fields: [ + ], + } + + }, + //--------------------------------------------------------------------- + log: function(evt) { + window.console.log(evt); + }, + //--------------------------------------------------------------------- + toggleFieldOptions: function (event) { + + let el = event.target; + + console.log('--->', el); + + let target = $(el).closest('.dropzone-field').find('.dropzone-field-options'); + + + console.log('--->', target); + target.toggle(); + + }, + //--------------------------------------------------------------------- + deleteGroup: function (group, index) { + this.item.groups.splice(index, 1); + this.updateItem(); + }, + //--------------------------------------------------------------------- + deleteGroupField: function (group, index) { + group.fields.splice(index, 1); + this.updateItem(); + }, + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + storeGroups: function () { + this.$Progress.start(); + let params = this.item.groups; + console.log('--->params', params); + let url = this.ajax_url+'/store/'+this.$route.params.id+'/groups'; + this.$vaah.ajax(url, params, this.storeGroupsAfter); + }, + //--------------------------------------------------------------------- + storeGroupsAfter: function (data, res) { + this.$Progress.finish(); + if(data){ + this.getItem(); + } + + }, + //--------------------------------------------------------------------- + cloneField: function({ id, name, slug, meta }) + { + + let item = { + name: null, + slug: null, + vh_cms_field_type_id: id, + meta: meta, + type: { + id: id, + name: name, + slug: slug, + meta: meta, + } + }; + + console.log('--->cloned item', item); + + + return item; + + + }, + //--------------------------------------------------------------------- + resetActiveItem: function () { + this.update('active_item', null); + this.$router.push({name:'blocks.list'}); + }, + + //--------------------------------------------------------------------- + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + } +} diff --git a/Vue/pages/blocks/Create.vue b/Vue/pages/blocks/Create.vue new file mode 100644 index 0000000..e74256b --- /dev/null +++ b/Vue/pages/blocks/Create.vue @@ -0,0 +1,175 @@ + + diff --git a/Vue/pages/blocks/CreateJs.js b/Vue/pages/blocks/CreateJs.js new file mode 100644 index 0000000..6e399da --- /dev/null +++ b/Vue/pages/blocks/CreateJs.js @@ -0,0 +1,227 @@ +import GlobalComponents from '../../vaahvue/helpers/GlobalComponents' +import draggable from 'vuedraggable'; + +let namespace = 'blocks'; + +export default { + computed:{ + root() {return this.$store.getters['root/state']}, + page() {return this.$store.getters[namespace+'/state']}, + ajax_url() {return this.$store.getters[namespace+'/state'].ajax_url}, + new_item() {return this.$store.getters[namespace+'/state'].new_item}, + }, + components:{ + ...GlobalComponents, + draggable, + }, + data() + { + return { + namespace: namespace, + is_content_loading: false, + is_btn_loading: null, + labelPosition: 'on-border', + params: {}, + local_action: null, + title: null, + new_status: null, + disable_status_editing: true, + edit_status_index: null, + } + }, + watch: { + $route(to, from) { + this.updateView() + }, + + 'new_item.name': { + deep: true, + handler(new_val, old_val) { + + if(new_val) + { + this.new_item.slug = this.$vaah.strToSlug(new_val); + this.updateNewItem(); + } + + } + }, + + 'new_item.plural': { + deep: true, + handler(new_val, old_val) { + + if(new_val) + { + this.new_item.plural_slug = this.$vaah.strToSlug(new_val); + this.updateNewItem(); + } + + } + }, + + 'new_item.singular': { + deep: true, + handler(new_val, old_val) { + + if(new_val) + { + this.new_item.singular_slug = this.$vaah.strToSlug(new_val); + this.updateNewItem(); + } + + } + }, + + }, + mounted() { + //---------------------------------------------------- + + //---------------------------------------------------- + this.onLoad(); + //---------------------------------------------------- + + //---------------------------------------------------- + }, + methods: { + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + update: function(name, value) + { + let update = { + state_name: name, + state_value: value, + namespace: this.namespace, + }; + this.$vaah.updateState(update); + }, + //--------------------------------------------------------------------- + updateNewItem: function() + { + let update = { + state_name: 'new_item', + state_value: this.new_item, + namespace: this.namespace, + }; + this.$vaah.updateState(update); + }, + //--------------------------------------------------------------------- + updateView: function() + { + this.$store.dispatch(this.namespace+'/updateView', this.$route); + }, + //--------------------------------------------------------------------- + onLoad: function() + { + this.is_content_loading = true; + this.updateView(); + this.getAssets(); + }, + //--------------------------------------------------------------------- + async reloadRootAssets() { + await this.$store.dispatch('root/reloadAssets'); + }, + //--------------------------------------------------------------------- + async getAssets() { + await this.$store.dispatch(namespace+'/getAssets'); + }, + + //--------------------------------------------------------------------- + addStatus: function() + { + this.new_item.content_statuses.push(this.new_status); + this.new_status = null; + this.update('new_item', this.new_item); + }, + //--------------------------------------------------------------------- + toggleEditStatus: function(status_index) + { + this.edit_status_index = status_index; + if(this.disable_status_editing) + { + this.disable_status_editing = false; + } else + { + this.disable_status_editing = true; + } + }, + //--------------------------------------------------------------------- + create: function () { + this.$Progress.start(); + let params = this.new_item; + + console.log('--->', params); + + let url = this.ajax_url+'/create'; + this.$vaah.ajax(url, params, this.createAfter); + }, + //--------------------------------------------------------------------- + createAfter: function (data, res) { + + this.$Progress.finish(); + + if(data) + { + this.$emit('eReloadList'); + + if(this.local_action === 'save-and-close') + { + this.saveAndClose(); + }else{ + //this.$router.push({name: 'blocks.list'}); + this.saveAndNew(); + + // this.$root.$emit('eReloadItem'); + } + + this.reloadRootAssets(); + + } + + }, + //--------------------------------------------------------------------- + setLocalAction: function (action) { + this.local_action = action; + this.store(); + }, + //--------------------------------------------------------------------- + saveAndClose: function () { + this.update('active_item', null); + this.$router.push({name:'blocks.list'}); + }, + //--------------------------------------------------------------------- + saveAndNew: function () { + this.update('active_item', null); + this.resetNewItem(); + }, + //--------------------------------------------------------------------- + resetNewItem: function() + { + let new_item = this.getNewItem(); + this.update('new_item', new_item); + }, + //--------------------------------------------------------------------- + getNewItem: function() + { + let new_item = { + name: null, + slug: null, + plural: null, + plural_slug: null, + singular: null, + singular_slug: null, + excerpt: null, + is_published: null, + is_commentable: null, + content_statuses: [ + 'draft', + 'published', + 'protected', + ], + meta: null, + }; + return new_item; + }, + //--------------------------------------------------------------------- + } +} diff --git a/Vue/pages/blocks/Edit.vue b/Vue/pages/blocks/Edit.vue new file mode 100644 index 0000000..ea31528 --- /dev/null +++ b/Vue/pages/blocks/Edit.vue @@ -0,0 +1,201 @@ + + + + diff --git a/Vue/pages/blocks/EditJs.js b/Vue/pages/blocks/EditJs.js new file mode 100644 index 0000000..a533d19 --- /dev/null +++ b/Vue/pages/blocks/EditJs.js @@ -0,0 +1,217 @@ +import GlobalComponents from '../../vaahvue/helpers/GlobalComponents' +import draggable from 'vuedraggable'; + +let namespace = 'blocks'; + +export default { + props: ['id'], + computed:{ + root() {return this.$store.getters['root/state']}, + page() {return this.$store.getters[namespace+'/state']}, + ajax_url() {return this.$store.getters[namespace+'/state'].ajax_url}, + item() {return this.$store.getters[namespace+'/state'].active_item}, + }, + components:{ + ...GlobalComponents, + draggable + + }, + data() + { + return { + namespace: namespace, + is_content_loading: false, + is_btn_loading: null, + labelPosition: 'on-border', + params: {}, + local_action: null, + title: null, + edit_status_index: null, + status: null, + disable_status_editing: true, + } + }, + watch: { + $route(to, from) { + this.updateView() + }, + + 'item.name': { + deep: true, + handler(new_val, old_val) { + + if(new_val) + { + this.item.slug = this.$vaah.strToSlug(new_val); + this.updateNewItem(); + } + + } + }, + + 'item.plural': { + deep: true, + handler(new_val, old_val) { + + if(new_val) + { + this.item.plural_slug = this.$vaah.strToSlug(new_val); + this.updateNewItem(); + } + + } + }, + + 'item.singular': { + deep: true, + handler(new_val, old_val) { + + if(new_val) + { + this.item.singular_slug = this.$vaah.strToSlug(new_val); + this.updateNewItem(); + } + + } + }, + + }, + mounted() { + //---------------------------------------------------- + this.onLoad(); + //---------------------------------------------------- + + //---------------------------------------------------- + }, + methods: { + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + update: function(name, value) + { + let update = { + state_name: name, + state_value: value, + namespace: this.namespace, + }; + this.$vaah.updateState(update); + }, + //--------------------------------------------------------------------- + updateView: function() + { + this.$store.dispatch(this.namespace+'/updateView', this.$route); + }, + //--------------------------------------------------------------------- + updateNewItem: function() + { + let update = { + state_name: 'item', + state_value: this.item, + namespace: this.namespace, + }; + this.$vaah.updateState(update); + }, + //--------------------------------------------------------------------- + onLoad: function() + { + this.is_content_loading = true; + + this.updateView(); + this.getAssets(); + this.getItem(); + }, + //--------------------------------------------------------------------- + async getAssets() { + await this.$store.dispatch(namespace+'/getAssets'); + }, + //--------------------------------------------------------------------- + getItem: function () { + this.$Progress.start(); + this.params = {}; + let url = this.ajax_url+'/item/'+this.$route.params.id; + this.$vaah.ajaxGet(url, this.params, this.getItemAfter); + }, + //--------------------------------------------------------------------- + getItemAfter: function (data, res) { + this.$Progress.finish(); + this.is_content_loading = false; + + if(data) + { + this.title = data.name; + this.update('active_item', data); + } else + { + //if item does not exist or delete then redirect to list + this.update('active_item', null); + this.$router.push({name: 'blocks.list'}); + } + }, + //--------------------------------------------------------------------- + store: function () { + this.$Progress.start(); + + let params = this.item; + + let url = this.ajax_url+'/store/'+this.item.id; + this.$vaah.ajax(url, params, this.storeAfter); + }, + //--------------------------------------------------------------------- + storeAfter: function (data, res) { + + this.$Progress.finish(); + + if(data) + { + this.$emit('eReloadList'); + + if(this.local_action === 'save-and-close') + { + this.saveAndClose() + }else{ + this.$router.push({name: 'blocks.view', params:{id:this.id}}); + this.$root.$emit('eReloadItem'); + } + + this.reloadRootAssets(); + + } + + }, + //--------------------------------------------------------------------- + async reloadRootAssets() { + await this.$store.dispatch('root/reloadAssets'); + }, + //--------------------------------------------------------------------- + setLocalAction: function (action) { + this.local_action = action; + this.store(); + }, + //--------------------------------------------------------------------- + saveAndClose: function () { + this.update('active_item', null); + this.$router.push({name:'blocks.list'}); + }, + //--------------------------------------------------------------------- + + //--------------------------------------------------------------------- + toggleEditStatus: function(status_index) + { + this.edit_status_index = status_index; + if(this.disable_status_editing) + { + this.disable_status_editing = false; + } else + { + this.disable_status_editing = true; + } + }, + //--------------------------------------------------------------------- + + addStatus: function() + { + this.item.content_statuses.push(this.status); + this.status = null; + this.update('item', this.item); + }, + } +} diff --git a/Vue/pages/blocks/List.vue b/Vue/pages/blocks/List.vue new file mode 100644 index 0000000..29859d8 --- /dev/null +++ b/Vue/pages/blocks/List.vue @@ -0,0 +1,332 @@ + + + + diff --git a/Vue/pages/blocks/ListJs.js b/Vue/pages/blocks/ListJs.js new file mode 100644 index 0000000..368fc31 --- /dev/null +++ b/Vue/pages/blocks/ListJs.js @@ -0,0 +1,354 @@ +import GlobalComponents from '../../vaahvue/helpers/GlobalComponents'; +import ListLargeView from './partials/ListLargeView'; +import ListMediumView from './partials/ListMediumView'; +import ListSmallView from './partials/ListSmallView'; + +let namespace = 'blocks'; + +export default { + computed:{ + root() {return this.$store.getters['root/state']}, + permissions() {return this.$store.getters['root/state'].permissions}, + page() {return this.$store.getters[namespace+'/state']}, + ajax_url() {return this.$store.getters[namespace+'/state'].ajax_url}, + query_string() {return this.$store.getters[namespace+'/state'].query_string}, + }, + components:{ + ...GlobalComponents, + ListLargeView, + ListMediumView, + ListSmallView, + + }, + data() + { + return { + namespace: namespace, + is_content_loading: false, + is_btn_loading: false, + assets: null, + selected_date: null, + search_delay: null, + search_delay_time: 800, + ids: [], + moduleSection: null, + } + }, + watch: { + $route(to, from) { + + + + this.updateView(); + this.updateQueryString(); + this.updateActiveItem(); + } + }, + mounted() { + //---------------------------------------------------- + this.onLoad(); + //---------------------------------------------------- + //---------------------------------------------------- + }, + methods: { + //--------------------------------------------------------------------- + update: function(name, value) + { + let update = { + state_name: name, + state_value: value, + namespace: this.namespace, + }; + this.$vaah.updateState(update); + }, + //--------------------------------------------------------------------- + updateView: function() + { + this.$store.dispatch(this.namespace+'/updateView', this.$route); + }, + //--------------------------------------------------------------------- + onLoad: function() + { + this.updateView(); + this.updateQueryString(); + this.getAssets(); + this.setDateFilter(); + }, + //--------------------------------------------------------------------- + toCreate: function() + { + this.update('active_item', null); + this.$router.push({name:'blocks.create'}); + }, + //--------------------------------------------------------------------- + updateQueryString: function() + { + let query = this.$vaah.removeEmpty(this.$route.query); + if(Object.keys(query).length) + { + for(let key in query) + { + this.query_string[key] = query[key]; + } + } + this.update('query_string', this.query_string); + this.$vaah.updateCurrentURL(this.query_string, this.$router); + }, + //--------------------------------------------------------------------- + async getAssets() { + await this.$store.dispatch(this.namespace+'/getAssets'); + this.getList(); + }, + //--------------------------------------------------------------------- + toggleFilters: function() + { + if(this.page.show_filters == false) + { + this.page.show_filters = true; + } else + { + this.page.show_filters = false; + } + + this.update('show_filters', this.page.show_filters); + + }, + //--------------------------------------------------------------------- + clearSearch: function () { + this.query_string.q = null; + this.update('query_string', this.query_string); + this.getList(); + }, + //--------------------------------------------------------------------- + setDateFilter: function() + { + if(this.query_string.from){ + let from = new Date(this.query_string.from); + + this.selected_date=[ + from + ]; + } + + if(this.query_string.to){ + let to = new Date(this.query_string.to); + + this.selected_date[1] = to; + } + }, + //--------------------------------------------------------------------- + resetPage: function() + { + + //reset query strings + this.resetQueryString(); + + //reset bulk actions + this.resetBulkAction(); + + this.resetSelectedDate(); + + //reload page list + this.getList(); + + }, + //--------------------------------------------------------------------- + resetSelectedDate: function() + { + this.selected_date = null; + }, + //--------------------------------------------------------------------- + resetQueryString: function() + { + for(let key in this.query_string) + { + if(key == 'page') + { + this.query_string[key] = 1; + } else if(key == 'sort_order') + { + this.query_string[key] = 'desc'; + } else + { + this.query_string[key] = null; + } + } + + this.update('query_string', this.query_string); + }, + //--------------------------------------------------------------------- + resetBulkAction: function() + { + this.page.bulk_action = { + selected_items: [], + data: {}, + action: null, + }; + this.update('bulk_action', this.page.bulk_action); + }, + //--------------------------------------------------------------------- + paginate: function(page=1) + { + this.query_string.page = page; + this.update('query_string', this.query_string); + this.getList(); + }, + //--------------------------------------------------------------------- + delayedSearch: function() + { + let self = this; + clearTimeout(this.search_delay); + this.search_delay = setTimeout(function() { + self.getList(); + }, this.search_delay_time); + + this.query_string.page = 1; + this.update('query_string', this.query_string); + + }, + //--------------------------------------------------------------------- + getList: function () { + this.$Progress.start(); + this.$vaah.updateCurrentURL(this.query_string, this.$router); + let url = this.ajax_url+'/list'; + this.$vaah.ajaxGet(url, this.query_string, this.getListAfter); + }, + //--------------------------------------------------------------------- + getListAfter: function (data, res) { + + this.update('is_list_loading', false); + + if(data){ + + console.log('--->data.list', data.list); + + this.update('list', data.list); + + + this.update('total_roles', data.totalRole); + this.update('total_users', data.totalUser); + + if(data.list.total === 0) + { + this.update('list_is_empty', true); + }else{ + this.update('list_is_empty', false); + } + + this.page.query_string.recount = null; + + this.update('query_string', this.page.query_string); + this.$vaah.updateCurrentURL(this.page.query_string, this.$router); + + this.is_btn_loading = false; + } + + this.$Progress.finish(); + + }, + //--------------------------------------------------------------------- + actions: function () { + + if(!this.page.bulk_action.action) + { + this.$vaah.toastErrors(['Select an action']); + return false; + } + + if(this.page.bulk_action.action == 'bulk-change-status'){ + if(!this.page.bulk_action.data.status){ + this.$vaah.toastErrors(['Select a status']); + return false; + } + } + + if(this.page.bulk_action.selected_items.length < 1) + { + this.$vaah.toastErrors(['Select a record']); + return false; + } + + this.$Progress.start(); + this.update('bulk_action', this.page.bulk_action); + let ids = this.$vaah.pluckFromObject(this.page.bulk_action.selected_items, 'id'); + + let params = { + inputs: ids, + data: this.page.bulk_action.data + }; + + let url = this.ajax_url+'/actions/'+this.page.bulk_action.action; + this.$vaah.ajax(url, params, this.actionsAfter); + }, + //--------------------------------------------------------------------- + actionsAfter: function (data, res) { + if(data) + { + this.$root.$emit('eReloadItem'); + this.resetBulkAction(); + this.getList(); + + this.$store.dispatch('root/reloadPermissions'); + } else + { + this.$Progress.finish(); + } + this.reloadRootAssets(); + }, + //--------------------------------------------------------------------- + async reloadRootAssets() { + await this.$store.dispatch('root/reloadAssets'); + }, + //--------------------------------------------------------------------- + sync: function () { + + this.page.query_string.recount = true; + + this.is_btn_loading = true; + + this.update('query_string', this.page.query_string); + this.getList(); + }, + //--------------------------------------------------------------------- + + //--------------------------------------------------------------------- + setFilter: function () { + + this.query_string.page = 1; + this.update('query_string', this.query_string); + + this.getList(); + + }, + //--------------------------------------------------------------------- + updateActiveItem: function () { + + if(this.$route.fullPath.includes('permissions/?')){ + this.update('active_item', null); + } + }, + + //--------------------------------------------------------------------- + hasPermission: function(slug) + { + return this.$vaah.hasPermission(this.permissions, slug); + }, + //--------------------------------------------------------------------- + setDateRange: function() + { + + if(this.selected_date.length > 0){ + let current_datetime = new Date(this.selected_date[0]); + this.query_string.from = current_datetime.getFullYear() + "-" + (current_datetime.getMonth() + 1) + "-" + current_datetime.getDate(); + + current_datetime = new Date(this.selected_date[1]); + this.query_string.to = current_datetime.getFullYear() + "-" + (current_datetime.getMonth() + 1) + "-" + current_datetime.getDate(); + + this.getList(); + } + + }, + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + } +} diff --git a/Vue/pages/blocks/View.vue b/Vue/pages/blocks/View.vue new file mode 100644 index 0000000..3ba53d0 --- /dev/null +++ b/Vue/pages/blocks/View.vue @@ -0,0 +1,176 @@ + + + + diff --git a/Vue/pages/blocks/ViewJs.js b/Vue/pages/blocks/ViewJs.js new file mode 100644 index 0000000..cdc6a55 --- /dev/null +++ b/Vue/pages/blocks/ViewJs.js @@ -0,0 +1,210 @@ +import GlobalComponents from '../../vaahvue/helpers/GlobalComponents' +import TableTrView from '../../vaahvue/reusable/TableTrView' +import TableTrActedBy from '../../vaahvue/reusable/TableTrActedBy' +import TableTrStatus from '../../vaahvue/reusable/TableTrStatus' + +let namespace = 'blocks'; + +export default { + computed:{ + root() {return this.$store.getters['root/state']}, + permissions() {return this.$store.getters['root/state'].permissions}, + page() {return this.$store.getters[namespace+'/state']}, + ajax_url() {return this.$store.getters[namespace+'/state'].ajax_url}, + item() {return this.$store.getters[namespace+'/state'].active_item}, + }, + components:{ + ...GlobalComponents, + TableTrView, + TableTrStatus, + TableTrActedBy, + }, + data() + { + return { + namespace: namespace, + is_btn_loading: false, + is_content_loading: false, + } + }, + watch: { + $route(to, from) { + this.updateView(); + this.getItem(); + } + }, + mounted() { + //---------------------------------------------------- + this.onLoad(); + //---------------------------------------------------- + this.$root.$on('eReloadItem', this.getItem); + //---------------------------------------------------- + this.$root.$on('eResetBulkActions', this.resetBulkAction); + //---------------------------------------------------- + //---------------------------------------------------- + }, + methods: { + //--------------------------------------------------------------------- + update: function(name, value) + { + let update = { + state_name: name, + state_value: value, + namespace: this.namespace, + }; + this.$vaah.updateState(update); + }, + //--------------------------------------------------------------------- + updateView: function() + { + this.$store.dispatch(this.namespace+'/updateView', this.$route); + }, + //--------------------------------------------------------------------- + onLoad: function() + { + this.is_content_loading = true; + + this.updateView(); + this.getAssets(); + this.getItem(); + }, + //--------------------------------------------------------------------- + async getAssets() { + await this.$store.dispatch(namespace+'/getAssets'); + }, + //--------------------------------------------------------------------- + getItem: function () { + this.$Progress.start(); + this.params = {}; + let url = this.ajax_url+'/item/'+this.$route.params.id; + this.$vaah.ajaxGet(url, this.params, this.getItemAfter); + }, + //--------------------------------------------------------------------- + getItemAfter: function (data, res) { + this.$Progress.finish(); + this.is_content_loading = false; + + if(data && data) + { + if(data.is_active == 1){ + data.is_active = 'Yes'; + }else{ + data.is_active = 'No'; + } + this.update('active_item', data); + } else + { + //if item does not exist or delete then redirect to list + this.update('active_item', null); + this.$router.push({name: 'perm.list'}); + } + }, + //--------------------------------------------------------------------- + actions: function (action) { + + this.$Progress.start(); + this.page.bulk_action.action = action; + this.update('bulk_action', this.page.bulk_action); + let params = { + inputs: [this.item.id], + data: null + }; + + let url = this.ajax_url+'/actions/'+this.page.bulk_action.action; + this.$vaah.ajax(url, params, this.actionsAfter); + + }, + //--------------------------------------------------------------------- + actionsAfter: function (data, res) { + let action = this.page.bulk_action.action; + if(data) + { + this.resetBulkAction(); + this.$emit('eReloadList'); + + if(action == 'bulk-delete') + { + this.$router.push({name: 'blocks.list'}); + } else + { + this.getItem(); + } + + } else + { + this.$Progress.finish(); + } + + this.reloadRootAssets(); + }, + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + resetBulkAction: function() + { + this.page.bulk_action = { + selected_items: [], + data: {}, + action: "", + }; + this.update('bulk_action', this.page.bulk_action); + }, + //--------------------------------------------------------------------- + confirmDelete: function() + { + let self = this; + this.$buefy.dialog.confirm({ + title: 'Deleting record', + message: 'Are you sure you want to delete the record? This action cannot be undone.', + confirmText: 'Delete', + type: 'is-danger', + hasIcon: true, + onConfirm: function () { + self.actions('bulk-delete'); + } + }) + }, + //--------------------------------------------------------------------- + isCopiable: function (label) { + + if( + label == 'id' || label == 'uuid' || label == 'slug' || label == 'plural_slug' || label == 'singular_slug' + ) + { + return true; + } + + return false; + + }, + //--------------------------------------------------------------------- + isUpperCase: function (label) { + + if( + label == 'id' || label == 'uuid' + ) + { + return true; + } + + return false; + + }, + //--------------------------------------------------------------------- + resetActiveItem: function () { + this.update('active_item', null); + this.$router.push({name:'blocks.list'}); + }, + //--------------------------------------------------------------------- + hasPermission: function(slug) + { + return this.$vaah.hasPermission(this.permissions, slug); + }, + //--------------------------------------------------------------------- + async reloadRootAssets() { + await this.$store.dispatch('root/reloadAssets'); + }, + //--------------------------------------------------------------------- + + //--------------------------------------------------------------------- + } +} diff --git a/Vue/pages/blocks/partials/ListLargeView.vue b/Vue/pages/blocks/partials/ListLargeView.vue new file mode 100644 index 0000000..ea07c2c --- /dev/null +++ b/Vue/pages/blocks/partials/ListLargeView.vue @@ -0,0 +1,118 @@ + + + diff --git a/Vue/pages/blocks/partials/ListLargeViewJs.js b/Vue/pages/blocks/partials/ListLargeViewJs.js new file mode 100644 index 0000000..68d537b --- /dev/null +++ b/Vue/pages/blocks/partials/ListLargeViewJs.js @@ -0,0 +1,113 @@ +let namespace = 'blocks'; +export default { + computed: { + root() {return this.$store.getters['root/state']}, + permissions() {return this.$store.getters['root/state'].permissions}, + page() {return this.$store.getters[namespace+'/state']}, + ajax_url() {return this.$store.getters[namespace+'/state'].ajax_url}, + query_string() {return this.$store.getters[namespace+'/state'].query_string}, + }, + components:{ + + }, + + data() + { + let obj = { + namespace: namespace, + icon_copy: "" + }; + + return obj; + }, + created() { + }, + mounted(){ + + }, + + watch: { + + }, + methods: { + //--------------------------------------------------------------------- + update: function(name, value) + { + let update = { + state_name: name, + state_value: value, + namespace: this.namespace, + }; + this.$vaah.updateState(update); + }, + //--------------------------------------------------------------------- + + //--------------------------------------------------------------------- + setRowClass: function(row, index) + { + + if(this.page.active_item && row.id == this.page.active_item.id) + { + return 'is-selected'; + } + + if(row.deleted_at != null) + { + return 'is-danger'; + } + + }, + //--------------------------------------------------------------------- + setActiveItem: function (item) { + this.update('active_item', item); + this.$router.push({name: 'blocks.view', params:{id:item.id}}) + }, + //--------------------------------------------------------------------- + changeStatus: function (id) { + this.$Progress.start(); + let url = this.ajax_url+'/actions/bulk-change-status'; + let params = { + inputs: [id], + data: null + }; + this.$vaah.ajax(url, params, this.changeStatusAfter); + }, + //--------------------------------------------------------------------- + changeStatusAfter: function (data,res) { + this.$emit('eReloadList'); + this.reloadRootAssets(); + this.update('is_list_loading', false); + + }, + //--------------------------------------------------------------------- + async reloadRootAssets() { + await this.$store.dispatch('root/reloadAssets'); + }, + //--------------------------------------------------------------------- + + //--------------------------------------------------------------------- + copiedData: function (data) { + + this.$vaah.toastSuccess(['copied']); + + // alertify.success('copied'); + + this.$vaah.console(data, 'copied data'); + + }, + //--------------------------------------------------------------------- + hasPermission: function(slug) + { + return this.$vaah.hasPermission(this.permissions, slug); + }, + //--------------------------------------------------------------------- + toContentStructure: function (item) { + this.update('active_item', item); + this.$router.push({name:'blocks.content.structure', params:{id:item.id}}); + + } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + } +} diff --git a/Vue/pages/blocks/partials/ListMediumView.vue b/Vue/pages/blocks/partials/ListMediumView.vue new file mode 100644 index 0000000..3b9d203 --- /dev/null +++ b/Vue/pages/blocks/partials/ListMediumView.vue @@ -0,0 +1,119 @@ + + + diff --git a/Vue/pages/blocks/partials/ListMediumViewJs.js b/Vue/pages/blocks/partials/ListMediumViewJs.js new file mode 100644 index 0000000..e240264 --- /dev/null +++ b/Vue/pages/blocks/partials/ListMediumViewJs.js @@ -0,0 +1,113 @@ +let namespace = 'blocks'; +export default { + computed: { + root() {return this.$store.getters['root/state']}, + permissions() {return this.$store.getters['root/state'].permissions}, + page() {return this.$store.getters[namespace+'/state']}, + ajax_url() {return this.$store.getters[namespace+'/state'].ajax_url}, + query_string() {return this.$store.getters[namespace+'/state'].query_string}, + }, + components:{ + + }, + + data() + { + let obj = { + namespace: namespace, + icon_copy: "" + }; + + return obj; + }, + created() { + }, + mounted(){ + + }, + + watch: { + + }, + methods: { + //--------------------------------------------------------------------- + update: function(name, value) + { + let update = { + state_name: name, + state_value: value, + namespace: this.namespace, + }; + this.$vaah.updateState(update); + }, + //--------------------------------------------------------------------- + + //--------------------------------------------------------------------- + setRowClass: function(row, index) + { + + if(this.page.active_item && row.id == this.page.active_item.id) + { + return 'is-selected'; + } + + if(row.deleted_at != null) + { + return 'is-danger'; + } + + }, + //--------------------------------------------------------------------- + setActiveItem: function (item) { + this.update('active_item', item); + this.$router.push({name: 'blocks.view', params:{id:item.id}}) + }, + //--------------------------------------------------------------------- + changeStatus: function (id) { + this.$Progress.start(); + let url = this.ajax_url+'/actions/bulk-change-status'; + let params = { + inputs: [id], + data: null + }; + this.$vaah.ajax(url, params, this.changeStatusAfter); + }, + //--------------------------------------------------------------------- + changeStatusAfter: function (data,res) { + this.$emit('eReloadList'); + this.reloadRootAssets(); + this.update('is_list_loading', false); + + }, + //--------------------------------------------------------------------- + async reloadRootAssets() { + await this.$store.dispatch('root/reloadAssets'); + }, + //--------------------------------------------------------------------- + + //--------------------------------------------------------------------- + copiedData: function (data) { + + this.$vaah.toastSuccess(['copied']); + + // alertify.success('copied'); + + this.$vaah.console(data, 'copied data'); + + }, + //--------------------------------------------------------------------- + hasPermission: function(slug) + { + return this.$vaah.hasPermission(this.permissions, slug); + }, + //--------------------------------------------------------------------- + toContentStructure: function (item) { + this.update('active_item', item); + this.$router.push({name:'blocks.content.structure', params:{id:item.id}}); + + } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + } +} diff --git a/Vue/pages/blocks/partials/ListSmallView.vue b/Vue/pages/blocks/partials/ListSmallView.vue new file mode 100644 index 0000000..9f709b3 --- /dev/null +++ b/Vue/pages/blocks/partials/ListSmallView.vue @@ -0,0 +1,56 @@ + + + diff --git a/Vue/pages/blocks/partials/ListSmallViewJs.js b/Vue/pages/blocks/partials/ListSmallViewJs.js new file mode 100644 index 0000000..e240264 --- /dev/null +++ b/Vue/pages/blocks/partials/ListSmallViewJs.js @@ -0,0 +1,113 @@ +let namespace = 'blocks'; +export default { + computed: { + root() {return this.$store.getters['root/state']}, + permissions() {return this.$store.getters['root/state'].permissions}, + page() {return this.$store.getters[namespace+'/state']}, + ajax_url() {return this.$store.getters[namespace+'/state'].ajax_url}, + query_string() {return this.$store.getters[namespace+'/state'].query_string}, + }, + components:{ + + }, + + data() + { + let obj = { + namespace: namespace, + icon_copy: "" + }; + + return obj; + }, + created() { + }, + mounted(){ + + }, + + watch: { + + }, + methods: { + //--------------------------------------------------------------------- + update: function(name, value) + { + let update = { + state_name: name, + state_value: value, + namespace: this.namespace, + }; + this.$vaah.updateState(update); + }, + //--------------------------------------------------------------------- + + //--------------------------------------------------------------------- + setRowClass: function(row, index) + { + + if(this.page.active_item && row.id == this.page.active_item.id) + { + return 'is-selected'; + } + + if(row.deleted_at != null) + { + return 'is-danger'; + } + + }, + //--------------------------------------------------------------------- + setActiveItem: function (item) { + this.update('active_item', item); + this.$router.push({name: 'blocks.view', params:{id:item.id}}) + }, + //--------------------------------------------------------------------- + changeStatus: function (id) { + this.$Progress.start(); + let url = this.ajax_url+'/actions/bulk-change-status'; + let params = { + inputs: [id], + data: null + }; + this.$vaah.ajax(url, params, this.changeStatusAfter); + }, + //--------------------------------------------------------------------- + changeStatusAfter: function (data,res) { + this.$emit('eReloadList'); + this.reloadRootAssets(); + this.update('is_list_loading', false); + + }, + //--------------------------------------------------------------------- + async reloadRootAssets() { + await this.$store.dispatch('root/reloadAssets'); + }, + //--------------------------------------------------------------------- + + //--------------------------------------------------------------------- + copiedData: function (data) { + + this.$vaah.toastSuccess(['copied']); + + // alertify.success('copied'); + + this.$vaah.console(data, 'copied data'); + + }, + //--------------------------------------------------------------------- + hasPermission: function(slug) + { + return this.$vaah.hasPermission(this.permissions, slug); + }, + //--------------------------------------------------------------------- + toContentStructure: function (item) { + this.update('active_item', item); + this.$router.push({name:'blocks.content.structure', params:{id:item.id}}); + + } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + } +} diff --git a/Vue/routes/routes.js b/Vue/routes/routes.js index 82a5379..b6aa3e2 100644 --- a/Vue/routes/routes.js +++ b/Vue/routes/routes.js @@ -132,6 +132,87 @@ routes_list = { routes.push(routes_list); + +import BlockList from "./../pages/blocks/List"; +import BlockCreate from "./../pages/blocks/Create"; +import BlockView from "./../pages/blocks/View"; +import BlockContentStructure from "./../pages/blocks/ContentStructure"; +import BlockEdit from "./../pages/blocks/Edit"; + +routes_list = { + path: '/blocks', + component: Backend, + props: true, + meta: { + middleware: [ + GetBackendAssets + ] + }, + children: [ + { + path: '/', + name: 'blocks.list', + component: BlockList, + props: true, + meta: { + middleware: [ + GetBackendAssets + ] + }, + children: [ + { + path: 'create', + name: 'blocks.create', + component: BlockCreate, + props: true, + meta: { + middleware: [ + GetBackendAssets + ] + }, + }, + { + path: 'content-structure/:id', + name: 'blocks.content.structure', + component: BlockContentStructure, + props: true, + meta: { + middleware: [ + GetBackendAssets + ] + }, + }, + { + path: 'view/:id', + name: 'blocks.view', + component: BlockView, + props: true, + meta: { + middleware: [ + GetBackendAssets + ] + }, + }, + { + path: 'edit/:id', + name: 'blocks.edit', + component: BlockEdit, + props: true, + meta: { + middleware: [ + GetBackendAssets + ] + }, + } + + ] + } + + ] +}; + +routes.push(routes_list); + /* |-------------------------------------------------------------------------- | Contents Routes diff --git a/Vue/store/modules/blocks.js b/Vue/store/modules/blocks.js new file mode 100644 index 0000000..e7ac501 --- /dev/null +++ b/Vue/store/modules/blocks.js @@ -0,0 +1,141 @@ +import {VaahHelper as Vaah} from "../../vaahvue/helpers/VaahHelper"; + +//---------Variables +let base_url = document.getElementsByTagName('base')[0].getAttribute("href"); +let debug = document.getElementById('debug').getAttribute('content'); +//---------/Variables + +let json_url = base_url+"/backend/cms/json"; +let ajax_url = base_url+"/backend/cms/blocks"; + +export default { + namespaced: true, + state: { + debug: debug, + base_url: base_url, + ajax_url: ajax_url, + json_url: json_url, + assets: null, + assets_is_fetching: null, + assets_reload: false, + list: null, + list_is_empty: false, + is_list_loading: false, + list_view: true, + active_item: null, + is_item_loading: false, + show_filters: false, + query_string: { + page: 1, + q: null, + trashed: null, + filter: null, + sort_by: null, + sort_order: 'desc', + }, + bulk_action:{ + selected_items: [], + data: {}, + action: null, + }, + new_item:{ + name: null, + slug: null, + plural: null, + plural_slug: null, + singular: null, + singular_slug: null, + excerpt: null, + is_published: null, + is_commentable: null, + content_statuses: [ + 'draft', + 'published', + 'protected', + ], + meta: null, + }, + + }, + //========================================================================= + mutations:{ + updateState: function (state, payload) { + state[payload.key] = payload.value; + }, + //----------------------------------------------------------------- + }, + //========================================================================= + actions:{ + //----------------------------------------------------------------- + async getAssets({ state, commit, dispatch, getters }) { + + if(!state.assets_is_fetching || !state.assets) + { + let payload = { + key: 'assets_is_fetching', + value: true + }; + commit('updateState', payload); + + let url = state.ajax_url+'/assets'; + + console.log('--->assets url', url); + + let params = {}; + let data = await Vaah.ajaxGet(url, params); + payload = { + key: 'assets', + value: data.data.data + }; + + commit('updateState', payload); + } + + }, + //----------------------------------------------------------------- + updateView({ state, commit, dispatch, getters }, payload) { + let list_view; + let update; + + if(payload && payload.name && payload.name == 'blocks.list') + { + list_view = 'large'; + + update = { + key: 'active_item', + value: null + }; + + commit('updateState', update); + + } + + if(payload.name == 'blocks.create' || payload.name == 'blocks.view' || payload.name == 'blocks.edit') + { + list_view = 'medium'; + }; + + if(payload.name == 'blocks.blocks.structure') + { + list_view = 'small'; + }; + + let view = { + key: 'list_view', + value: list_view + }; + + commit('updateState', view); + + }, + //----------------------------------------------------------------- + }, + //========================================================================= + getters:{ + state(state) {return state;}, + assets(state) {return state.assets;}, + permissions(state) {return state.permissions;}, + is_logged_in(state) {return state.is_logged_in;}, + } + +} diff --git a/Vue/store/store.js b/Vue/store/store.js index 49c446c..1c90c24 100644 --- a/Vue/store/store.js +++ b/Vue/store/store.js @@ -5,6 +5,7 @@ Vue.use(Vuex); import root from './modules/root'; import content_types from './modules/content_types'; +import blocks from './modules/blocks'; import contents from './modules/contents'; import menus from './modules/menus'; @@ -12,6 +13,7 @@ export const store = new Vuex.Store({ modules: { root: root, content_types: content_types, + blocks: blocks, contents: contents, menus: menus, } From cac0ced482e9193ba15ad5f939274205dc609ff7 Mon Sep 17 00:00:00 2001 From: vikram chand Date: Fri, 19 Feb 2021 16:22:12 +0530 Subject: [PATCH 04/21] Added: add migration --- .../2021_02_19_151111_vh_cms_blocks_table.php | 50 +++++++++++++++++++ Vue/pages/blocks/Create.vue | 2 +- Vue/pages/blocks/List.vue | 2 +- Vue/pages/contents/Edit.vue | 10 ++-- 4 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 Database/Migrations/2021_02_19_151111_vh_cms_blocks_table.php diff --git a/Database/Migrations/2021_02_19_151111_vh_cms_blocks_table.php b/Database/Migrations/2021_02_19_151111_vh_cms_blocks_table.php new file mode 100644 index 0000000..acd8b63 --- /dev/null +++ b/Database/Migrations/2021_02_19_151111_vh_cms_blocks_table.php @@ -0,0 +1,50 @@ +increments('id'); + $table->uuid('uuid')->nullable()->index(); + + $table->integer('vh_theme_id')->nullable()->index(); + $table->integer('vh_theme_location_id')->nullable()->index(); + $table->string('name')->nullable()->index(); + $table->string('slug')->nullable()->index(); + $table->text('content')->nullable(); + $table->dateTime('is_published_at')->nullable()->index(); + $table->string('status')->nullable()->index(); + + $table->text('meta')->nullable(); + + $table->integer('created_by')->nullable()->index(); + $table->integer('updated_by')->nullable()->index(); + $table->integer('deleted_by')->nullable()->index(); + $table->timestamps(); + $table->softDeletes(); + $table->index(['created_at', 'updated_at', 'deleted_at']); + + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('vh_cms_blocks'); + } +} diff --git a/Vue/pages/blocks/Create.vue b/Vue/pages/blocks/Create.vue index e74256b..f76b094 100644 --- a/Vue/pages/blocks/Create.vue +++ b/Vue/pages/blocks/Create.vue @@ -8,7 +8,7 @@
- Create New Content Type + Create New Block
diff --git a/Vue/pages/blocks/List.vue b/Vue/pages/blocks/List.vue index 29859d8..b2bba14 100644 --- a/Vue/pages/blocks/List.vue +++ b/Vue/pages/blocks/List.vue @@ -20,7 +20,7 @@
- Content Types + Blocks
diff --git a/Vue/pages/contents/Edit.vue b/Vue/pages/contents/Edit.vue index f54c42f..dffca1e 100644 --- a/Vue/pages/contents/Edit.vue +++ b/Vue/pages/contents/Edit.vue @@ -1,8 +1,12 @@