Skip to content

Commit 6fb0a15

Browse files
committed
feat: Add BREAD
1 parent c8e1cf8 commit 6fb0a15

File tree

89 files changed

+5244
-158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+5244
-158
lines changed

coreui/src/containers/TheSidebar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export default {
109109
this.show = sidebarClosed ? true : 'responsive'
110110
})
111111
let self = this;
112-
axios.get('/api/menu?token=' + localStorage.getItem("api_token") )
112+
axios.get( '/api/menu?token=' + localStorage.getItem("api_token") )
113113
.then(function (response) {
114114
self.nav = self.rebuildData(response.data);
115115
}).catch(function (error) {

coreui/src/router/index.js

Lines changed: 131 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,32 @@ const Note = () => import('@/views/notes/Note')
6464
const EditNote = () => import('@/views/notes/EditNote')
6565
const CreateNote = () => import('@/views/notes/CreateNote')
6666

67+
//Roles
68+
const Roles = () => import('@/views/roles/Roles')
69+
const Role = () => import('@/views/roles/Role')
70+
const EditRole = () => import('@/views/roles/EditRole')
71+
const CreateRole = () => import('@/views/roles/CreateRole')
72+
73+
//Bread
74+
const Breads = () => import('@/views/bread/Breads')
75+
const Bread = () => import('@/views/bread/Bread')
76+
const EditBread = () => import('@/views/bread/EditBread')
77+
const CreateBread = () => import('@/views/bread/CreateBread')
78+
const DeleteBread = () => import('@/views/bread/DeleteBread')
79+
80+
//Resources
81+
const Resources = () => import('@/views/resources/Resources')
82+
const CreateResource = () => import('@/views/resources/CreateResources')
83+
const Resource = () => import('@/views/resources/Resource')
84+
const EditResource = () => import('@/views/resources/EditResource')
85+
const DeleteResource = () => import('@/views/resources/DeleteResource')
86+
6787
const EditMenu = () => import('@/views/menu/EditMenu')
6888
const Media = () => import('@/views/media/Media')
6989

90+
91+
92+
7093
Vue.use(Router)
7194

7295
export default new Router({
@@ -139,7 +162,7 @@ function configRoutes () {
139162
{
140163
path: ':id/edit',
141164
meta: { label: 'Edit User' },
142-
name: 'EditUser',
165+
name: 'Edit User',
143166
component: EditUser
144167
},
145168
]
@@ -158,7 +181,7 @@ function configRoutes () {
158181
{
159182
path: 'create',
160183
meta: { label: 'Create Note' },
161-
name: 'CreateNote',
184+
name: 'Create Note',
162185
component: CreateNote
163186
},
164187
{
@@ -170,11 +193,116 @@ function configRoutes () {
170193
{
171194
path: ':id/edit',
172195
meta: { label: 'Edit Note' },
173-
name: 'EditNote',
196+
name: 'Edit Note',
174197
component: EditNote
175198
},
176199
]
177200
},
201+
{
202+
path: 'roles',
203+
meta: { label: 'Roles'},
204+
component: {
205+
render (c) { return c('router-view') }
206+
},
207+
children: [
208+
{
209+
path: '',
210+
component: Roles,
211+
},
212+
{
213+
path: 'create',
214+
meta: { label: 'Create Role' },
215+
name: 'Create Note',
216+
component: CreateRole
217+
},
218+
{
219+
path: ':id',
220+
meta: { label: 'Role Details'},
221+
name: 'Role',
222+
component: Role,
223+
},
224+
{
225+
path: ':id/edit',
226+
meta: { label: 'Edit Role' },
227+
name: 'Edit Role',
228+
component: EditRole
229+
},
230+
]
231+
},
232+
{
233+
path: 'bread',
234+
meta: { label: 'Bread'},
235+
component: {
236+
render (c) { return c('router-view') }
237+
},
238+
children: [
239+
{
240+
path: '',
241+
component: Breads,
242+
},
243+
{
244+
path: 'create',
245+
meta: { label: 'Create Bread' },
246+
name: 'CreateBread',
247+
component: CreateBread
248+
},
249+
{
250+
path: ':id',
251+
meta: { label: 'Bread Details'},
252+
name: 'Bread',
253+
component: Bread,
254+
},
255+
{
256+
path: ':id/edit',
257+
meta: { label: 'Edit Bread' },
258+
name: 'Edit Bread',
259+
component: EditBread
260+
},
261+
{
262+
path: ':id/delete',
263+
meta: { label: 'Delete Bread' },
264+
name: 'Delete Bread',
265+
component: DeleteBread
266+
},
267+
]
268+
},
269+
{
270+
path: 'resource',
271+
meta: { label: 'Resources'},
272+
component: {
273+
render (c) { return c('router-view') }
274+
},
275+
children: [
276+
{
277+
path: ':bread/resource',
278+
component: Resources,
279+
},
280+
{
281+
path: ':bread/resource/create',
282+
meta: { label: 'Create Resource' },
283+
name: 'CreateResource',
284+
component: CreateResource
285+
},
286+
{
287+
path: ':bread/resource/:id',
288+
meta: { label: 'Resource Details'},
289+
name: 'Resource',
290+
component: Resource,
291+
},
292+
{
293+
path: ':bread/resource/:id/edit',
294+
meta: { label: 'Edit Resource' },
295+
name: 'Edit Resource',
296+
component: EditResource
297+
},
298+
{
299+
path: ':bread/resource/:id/delete',
300+
meta: { label: 'Delete Resource' },
301+
name: 'Delete Resource',
302+
component: DeleteResource
303+
},
304+
]
305+
},
178306
{
179307
path: 'base',
180308
redirect: '/base/cards',

coreui/src/views/bread/Bread.vue

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<template>
2+
<CRow>
3+
<CCol cols="12" lg="6">
4+
<CCard no-header>
5+
<CCardBody>
6+
<h3>Single BREAD</h3>
7+
8+
<CButton color="primary" @click="goBack">Back</CButton>
9+
<p class="mt-2">Form name: <strong>{{ form.name }}</strong></p>
10+
<p>Database table name: <strong>{{ form.table_name }}</strong></p>
11+
<p>Records on one page of table: <strong>{{ form.pagination }}</strong></p>
12+
<p>Enable Show button in table: {{ form.read }}</p>
13+
<p>Enable Edit button in table: {{ form.edit }}</p>
14+
<p>Enable Add button in table: {{ form.add }}</p>
15+
<p>Enable Delete button in table: {{ form.delete }}</p>
16+
17+
<ShowBreadFieldCard
18+
v-for="formField in formFields"
19+
v-bind:key="formField.id"
20+
:formField="formField"
21+
/>
22+
23+
<CButton color="primary" @click="goBack">Back</CButton>
24+
</CCardBody>
25+
</CCard>
26+
</CCol>
27+
</CRow>
28+
</template>
29+
30+
<script>
31+
import ShowBreadFieldCard from './ShowBreadFieldCard'
32+
import axios from 'axios'
33+
export default {
34+
name: 'Bread',
35+
components:{
36+
'ShowBreadFieldCard': ShowBreadFieldCard
37+
},
38+
data: () => {
39+
return {
40+
form: {
41+
name: '',
42+
table_name: '',
43+
pagination: '',
44+
read: '',
45+
edit: '',
46+
add: '',
47+
delete: '',
48+
},
49+
formFields: [],
50+
}
51+
},
52+
methods: {
53+
goBack() {
54+
this.$router.go(-1)
55+
}
56+
},
57+
mounted: function(){
58+
let self = this;
59+
axios.get( '/api/bread/' + self.$route.params.id + '?token=' + localStorage.getItem("api_token"))
60+
.then(function (response) {
61+
self.form = response.data.form
62+
self.formFields = response.data.formFields
63+
}).catch(function (error) {
64+
console.log(error);
65+
self.$router.push({ path: '/login' })
66+
});
67+
}
68+
}
69+
70+
71+
</script>

coreui/src/views/bread/Breads.vue

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<template>
2+
<CRow>
3+
<CCol cols="12" xl="12">
4+
<transition name="slide">
5+
<CCard>
6+
<CCardBody>
7+
<h4>Breads</h4>
8+
<CButton color="primary" @click="createBread()">Create Bread</CButton>
9+
<CAlert
10+
:show.sync="dismissCountDown"
11+
color="primary"
12+
fade
13+
>
14+
({{dismissCountDown}}) {{ message }}
15+
</CAlert>
16+
<CDataTable
17+
hover
18+
:items="items"
19+
:fields="fields"
20+
:items-per-page="10"
21+
pagination
22+
>
23+
<template #name="{item}">
24+
<td>
25+
<strong>{{item.name}}</strong>
26+
</td>
27+
</template>
28+
<template #show="{item}">
29+
<td>
30+
<CButton color="primary" @click="showBread( item.id )">Show</CButton>
31+
</td>
32+
</template>
33+
<template #edit="{item}">
34+
<td>
35+
<CButton color="primary" @click="editBread( item.id )">Edit</CButton>
36+
</td>
37+
</template>
38+
<template #delete="{item}">
39+
<td>
40+
<CButton color="danger" @click="deleteBread( item.id )">Delete</CButton>
41+
</td>
42+
</template>
43+
</CDataTable>
44+
</CCardBody>
45+
</CCard>
46+
</transition>
47+
</CCol>
48+
</CRow>
49+
</template>
50+
51+
<script>
52+
import axios from 'axios'
53+
54+
export default {
55+
name: 'Breads',
56+
data: () => {
57+
return {
58+
items: [],
59+
fields: ['name', 'show', 'edit', 'delete'],
60+
currentPage: 1,
61+
perPage: 5,
62+
totalRows: 0,
63+
message: '',
64+
showMessage: false,
65+
dismissSecs: 7,
66+
dismissCountDown: 0,
67+
showDismissibleAlert: false
68+
}
69+
},
70+
computed: {
71+
},
72+
methods: {
73+
breadLink (id) {
74+
return `bread/${id.toString()}`
75+
},
76+
editLink (id) {
77+
return `bread/${id.toString()}/edit`
78+
},
79+
showBread ( id ) {
80+
const breadLink = this.breadLink( id )
81+
this.$router.push({path: breadLink})
82+
},
83+
editBread ( id ) {
84+
const editLink = this.editLink( id )
85+
this.$router.push({path: editLink})
86+
},
87+
deleteBread ( id ) {
88+
const deleteLink = `bread/${id.toString()}/delete`
89+
this.$router.push({path: deleteLink})
90+
},
91+
createBread () {
92+
this.$router.push({path: 'bread/create'})
93+
},
94+
countDownChanged (dismissCountDown) {
95+
this.dismissCountDown = dismissCountDown
96+
},
97+
showAlert () {
98+
this.dismissCountDown = this.dismissSecs
99+
},
100+
getBreads (){
101+
let self = this;
102+
axios.get( '/api/bread?token=' + localStorage.getItem("api_token") )
103+
.then(function (response) {
104+
self.items = response.data;
105+
}).catch(function (error) {
106+
console.log(error);
107+
self.$router.push({ path: '/login' });
108+
});
109+
}
110+
},
111+
mounted: function(){
112+
this.getBreads();
113+
}
114+
}
115+
</script>
116+
117+
<style scoped>
118+
.card-body >>> table > tbody > tr > td {
119+
cursor: pointer;
120+
}
121+
</style>

0 commit comments

Comments
 (0)