|
1 | 1 | <template>
|
2 | | - <b-card header="Home"> |
3 | | - You are logged in |
| 2 | + <b-card header="Posts"> |
| 3 | + <b-button v-b-modal.modal-create class="mb-2" variant="primary">Create Post</b-button> |
| 4 | + |
| 5 | + <b-modal v-model="create_modal_show" id="modal-create" no-close-on-backdrop content-class="shadow" title="Create Post"> |
| 6 | + <b-form @submit.prevent="register" @keydown="form.onKeydown($event)"> |
| 7 | + <b-form-group |
| 8 | + label="Title:" |
| 9 | + label-for="title"> |
| 10 | + <b-form-input type="text" id="title" name="title" :class="{ 'is-invalid': form.errors.has('title') }" v-model="form.title"></b-form-input> |
| 11 | + <has-error :form="form" field="title" /> |
| 12 | + </b-form-group> |
| 13 | + <b-form-group |
| 14 | + label="Author:" |
| 15 | + label-for="author"> |
| 16 | + <b-form-select id="author" name="author" :class="{ 'is-invalid': form.errors.has('author') }" v-model="form.author" :options="options"></b-form-select> |
| 17 | +<!-- <b-form-input id="user" name="user" :class="{ 'is-invalid': form.errors.has('user') }" v-model="form.user" list="my-list-id"></b-form-input>--> |
| 18 | +<!-- <datalist id="my-list-id">--> |
| 19 | +<!-- <option v-for="option in options">{{ option.text }}</option>--> |
| 20 | +<!-- </datalist>--> |
| 21 | + <has-error :form="form" field="author" /> |
| 22 | + </b-form-group> |
| 23 | + <b-form-group |
| 24 | + label="Description:" |
| 25 | + label-for="description"> |
| 26 | + <b-form-textarea id="description" name="description" :class="{ 'is-invalid': form.errors.has('description') }" v-model="form.description" rows="3" max-rows="6"></b-form-textarea> |
| 27 | + <has-error :form="form" field="description" /> |
| 28 | + </b-form-group> |
| 29 | + </b-form> |
| 30 | + <template #modal-footer> |
| 31 | + <div class="w-100"> |
| 32 | + <b-button |
| 33 | + variant="danger" |
| 34 | + class="float-right" |
| 35 | + @click="create_modal_show=false" |
| 36 | + > |
| 37 | + Close |
| 38 | + </b-button> |
| 39 | + <b-button |
| 40 | + type="submit" |
| 41 | + variant="primary" |
| 42 | + class="float-right mr-2" |
| 43 | + > |
| 44 | + Save |
| 45 | + </b-button> |
| 46 | + </div> |
| 47 | + </template> |
| 48 | + </b-modal> |
| 49 | + <b-modal v-model="edit_modal_show" id="modal-edit" no-close-on-backdrop content-class="shadow" title="Edit Post"> |
| 50 | + <b-form @submit.prevent="register" @keydown="editform.onKeydown($event)"> |
| 51 | + <b-form-group |
| 52 | + label="Title:" |
| 53 | + label-for="title"> |
| 54 | + <b-form-input type="text" id="title" name="title" :class="{ 'is-invalid': editform.errors.has('title') }" v-model="editform.title"></b-form-input> |
| 55 | + <has-error :form="editform" field="title" /> |
| 56 | + </b-form-group> |
| 57 | + <b-form-group |
| 58 | + label="Author:" |
| 59 | + label-for="author"> |
| 60 | +<!-- <b-form-select id="user" name="user" :class="{ 'is-invalid': editform.errors.has('user') }" v-model="editform.user" :options="options"></b-form-select>--> |
| 61 | + <b-form-input id="author" name="author" :class="{ 'is-invalid': form.errors.has('author') }" v-model="form.author" list="my-list-id"></b-form-input> |
| 62 | + <datalist id="my-list-id"> |
| 63 | + <option v-for="option in options">{{ option.text }}</option> |
| 64 | + </datalist> |
| 65 | + <has-error :form="editform" field="author" /> |
| 66 | + </b-form-group> |
| 67 | + <b-form-group |
| 68 | + label="Description:" |
| 69 | + label-for="description"> |
| 70 | + <b-form-textarea id="description" name="description" :class="{ 'is-invalid': editform.errors.has('description') }" v-model="editform.description" rows="3" max-rows="6"></b-form-textarea> |
| 71 | + <has-error :form="editform" field="description" /> |
| 72 | + </b-form-group> |
| 73 | + </b-form> |
| 74 | + <template #modal-footer> |
| 75 | + <div class="w-100"> |
| 76 | + <b-button |
| 77 | + variant="danger" |
| 78 | + class="float-right" |
| 79 | + @click="edit_modal_show=false" |
| 80 | + > |
| 81 | + Close |
| 82 | + </b-button> |
| 83 | + <b-button |
| 84 | + type="submit" |
| 85 | + variant="primary" |
| 86 | + class="float-right mr-2" |
| 87 | + > |
| 88 | + Save |
| 89 | + </b-button> |
| 90 | + </div> |
| 91 | + </template> |
| 92 | + </b-modal> |
| 93 | + <b-table striped hover :items="items"> |
| 94 | + <template #cell(action)="data"> |
| 95 | + <b-button size="sm" @click="openModal(data.value)" variant="info">Edit</b-button> |
| 96 | + <b-button size="sm" @click="delete(data.value)" variant="danger">Delete</b-button> |
| 97 | + </template> |
| 98 | + </b-table> |
4 | 99 | </b-card>
|
5 | 100 | </template>
|
6 | 101 |
|
7 | 102 | <script>
|
| 103 | +import Form from "vform"; |
| 104 | + |
8 | 105 | export default {
|
9 | | - middleware: 'auth', |
| 106 | + middleware: 'auth', |
| 107 | + data() { |
| 108 | + return { |
| 109 | + create_modal_show: false, |
| 110 | + edit_modal_show: false, |
| 111 | + items: [ |
| 112 | + { title: 'Title1', author: 'Dickerson', description: 'Macdonald', action: 2 }, |
| 113 | + { title: 'Title2', author: 'Larsen', description: 'Shaw', action: 1 }, |
| 114 | + { title: 'Title3', author: 'Geneva', description: 'Wilson', action: 3 }, |
| 115 | + { title: 'Title4', author: 'Jami', description: 'Carney', action: 4 } |
| 116 | + ], |
| 117 | + options: [ |
| 118 | + { value: 'a', text: 'This is First option'}, |
| 119 | + { value: 'b', text: 'Selected Option'} |
| 120 | + ], |
| 121 | + form: new Form({ |
| 122 | + title: '', |
| 123 | + author: "a", |
| 124 | + description: '' |
| 125 | + }), |
| 126 | + editform: new Form({ |
| 127 | + id: '', |
| 128 | + title: '', |
| 129 | + author: "Geneva", |
| 130 | + description: '' |
| 131 | + }) |
| 132 | + } |
| 133 | + }, |
| 134 | + methods: { |
| 135 | + openModal(id) { |
| 136 | + this.edit_modal_show = true |
| 137 | + this.editform.id = "Title3" |
| 138 | + this.editform.title = "Title3" |
| 139 | + this.editform.author = "Geneva" |
| 140 | + this.editform.description = "Wilson" |
| 141 | + }, |
| 142 | + delete(id) { |
| 143 | + |
| 144 | + } |
| 145 | + } |
10 | 146 | }
|
11 | 147 | </script>
|
0 commit comments