Skip to content

Commit

Permalink
Merge pull request #72 from webreinvent/feature/crud-command-fixes
Browse files Browse the repository at this point in the history
feature -> develop | vue 3 crud fixes
  • Loading branch information
themodernpk authored Jun 26, 2024
2 parents 47f3d2e + b755c04 commit 06d6d4a
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const toggleCreateMenu = (event) => {

<div class="grid" v-if="store.assets">

<div :class="route.params && route.params.id ? 'col-6' : 'col'">
<div :class="'col-'+store.list_view_width">
<Panel class="is-small">

<template class="p-1" #header>
Expand Down
21 changes: 4 additions & 17 deletions skeletons/vaahcms/module-vue3/Vue/vaahvue/pinia/vaah.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,12 @@ export const vaah = defineStore({

//----------------------------------------------------------
processResponse: function (response, show_success) {
if (
response.data.failed || response.data.success === false
) {

if (response.data.messages) {
this.toastErrors(response.data.messages)
}

if (response.data.errors) {
this.toastErrors(response.data.errors)
}

if (response.data.errors) {
this.toastErrors(response.data.errors)
}

if (
response.data.success
&& response.data.success === true
&& response.data.messages
&& show_success === true
if (response.data.messages
&& show_success === true
) {
this.toastSuccess(response.data.messages)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@ const store = use<%= model_name %>Store();
const route = useRoute();
const useVaah = vaah();
const menu_pt = ref({
menuitem: ({ props }) => ({
class: route.path === props.item.route ? 'p-focus' : ''
})
});
const sidebar_menu_items = ref([
{
label: '<%= controller_name %>',
items: [
{
label: 'General',
icon: 'pi pi-cog',
to:{ path: '/<%= controller_name_lower %>/general' }
route:'/<%= controller_name_lower %>/general'
}
]},
]);
Expand All @@ -37,7 +43,21 @@ onMounted(async () => {
<template>
<div class="grid justify-content-center">
<div class="col-fixed">
<Menu :model="sidebar_menu_items" />
<Menu :model="sidebar_menu_items"
:pt="menu_pt">
<template #item="{ item, props }">
<router-link v-if="item.route" v-slot="{ href, navigate }" :to="item.route" custom>
<a v-ripple :href="href" v-bind="props.action" @click="navigate">
<span :class="item.icon" />
<span class="ml-2">{{ item.label }}</span>
</a>
</router-link>
<a v-else v-ripple :href="item.url" :target="item.target" v-bind="props.action">
<span :class="item.icon" />
<span class="ml-2">{{ item.label }}</span>
</a>
</template>
</Menu>
</div>
<div class="col">
<router-view></router-view>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ const openTaxonomyTypeModal = () => {


<Column field="slug" header="Slug"
:sortable="false"
class="flex align-items-center"
>
:sortable="false">
<template #body="prop">
{{ prop.data.slug }}

Expand All @@ -81,13 +79,11 @@ const openTaxonomyTypeModal = () => {
/>
</template>
</Column>
<column></column>

<Column field="type" header="Type"
:sortable="false"
class="flex align-items-center"
>
:sortable="false">
<template #body="prop">
<p v-if="prop.data.type"> {{ prop.data.type.name }} </p>
{{ prop.data.type.name }}

<Button class="p-button-tiny p-button-text"
data-testid="<%= controller_name_lower %>-table-to-manage-taxonomy-type-modal"
Expand All @@ -104,7 +100,7 @@ const openTaxonomyTypeModal = () => {
:sortable="true"
>
<template #body="prop">
{{ useVaah.ago(prop.data.updated_at) }}
{{ useVaah.toLocalTimeShortFormat(prop.data.updated_at) }}
</template>
</Column>

Expand Down
10 changes: 10 additions & 0 deletions skeletons/vaahcms/users/Http/Controllers/Controller.php.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,16 @@ class <%= controller_name %>Controller extends Controller
{

try {

$is_restricted = <%= model_name %>::restrictedActions($action, $id);

if(isset($is_restricted['success']) && !$is_restricted['success'])
{
$response = <%= model_name %>::getItem($id);
$response['errors'] = $is_restricted['errors'];
return response()->json($response);
}

$response = <%= model_name %>::itemAction($request,$id,$action);
} catch (\Exception $e) {
$response = [];
Expand Down
2 changes: 1 addition & 1 deletion skeletons/vaahcms/users/Vue/pages/template/List.vue.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ onMounted(async () => {
<template>
<div class="grid">
<div :class="'col-'+store.list_view_width">
<Panel>
<Panel class="is-small">
<template class="p-1" #header>
<div class="flex flex-row">
<div >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,7 @@ const toggleBulkMenuState = (event) => {
:popup="true"
/>
<!--/selected_menu-->

<!--bulk_menu-->
<Button class="p-button-sm ml-1"
icon="pi pi-ellipsis-h"
aria-haspopup="true"
aria-controls="bulk_menu_state"
data-testid="<%= controller_name_lower %>-action_bulk_menu"
@click="toggleBulkMenuState"
/>

<Menu ref="bulk_menu_state"
:model="store.list_bulk_menu"
:popup="true"
/>
<!--/bulk_menu-->

</div>
<!--/left-->

Expand Down Expand Up @@ -109,6 +95,22 @@ const toggleBulkMenuState = (event) => {
data-testid="<%= controller_name_lower %>-action_reset"
@click="store.resetQuery()"
/>

<!--bulk_menu-->
<Button
type="button"
@click="toggleBulkMenuState"
severity="danger" outlined
data-testid="<%= controller_name_lower %>-actions-bulk-menu"
aria-haspopup="true"
aria-controls="bulk_menu_state"
class="ml-1 p-button-sm">
<i class="pi pi-ellipsis-v"></i>
</Button>
<Menu ref="bulk_menu_state"
:model="store.list_bulk_menu"
:popup="true" />
<!--/bulk_menu-->
</div>
</div>

Expand Down
3 changes: 3 additions & 0 deletions skeletons/vaahcms/users/Vue/stores/store-template.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,9 @@ export const use<%= model_name %>Store = defineStore({
method: method,
show_success: false
};

options.params.query = vaah().clone(this.query);

await vaah().ajax(
url,
this.updateListAfter,
Expand Down

0 comments on commit 06d6d4a

Please sign in to comment.