Browse Source

Added multi select to listview

master
Kobus 5 years ago
parent
commit
6a79d174e1

+ 22
- 18
src/components/admin/status/timeshareAdminPage.vue View File

@@ -1,40 +1,44 @@
1 1
 <template>
2
-  <!-- <section class="intro-single"> -->
3
-  <div class="container">
2
+  <div>
3
+    <br />
4 4
     <br />
5 5
     <br />
6 6
     <br />
7 7
     <br />
8 8
     <div class="row">
9
-      <div class="col-md-12 col-lg-8">
10
-        <!-- <div class="title-single-box"> -->
11
-        <!-- <h1 class="title-single" style="text-align:left;">Timeshare Admin</h1> -->
12
-        <!-- </div> -->
13
-        <div class="title-box-d">
14
-          <h1 class="title-d" style="text-align:left; font-size: 250%">Timeshare Admin</h1>
15
-        </div>
16
-        <br />
9
+      <div class="offset-1 col-md-10">
10
+        <ListView :items="items" :editable="true" @onEdit="onEdit" />
17 11
       </div>
18 12
     </div>
19
-    <div id="table" class="col-xs-12 table-responsive">
20
-      <datatable :columns="columns" :data="rows"></datatable>
21
-    </div>
22 13
   </div>
23
-  <!-- </section> -->
24 14
 </template>
25 15
 <script>
26 16
 import { mapState, mapActions } from 'vuex';
17
+import Log from '../../../assets/Log';
18
+import ListView from '../../shared/listView.vue';
27 19
 
28 20
 export default {
29 21
   name: 'TimeshareAdmin',
30
-  created() {
31
-    this.gettimeshareAdmin();
22
+  components: {
23
+    ListView,
24
+  },
25
+  data() {
26
+    return {
27
+      user: Log.getUser(),
28
+    };
29
+  },
30
+  mounted() {
31
+    console.log(this.user.id);
32
+    this.getItems(this.user.id);
32 33
   },
33 34
   computed: {
34
-    ...mapState('status', ['timeshareAdmin']),
35
+    ...mapState('myWeeks', ['items']),
35 36
   },
36 37
   methods: {
37
-    ...mapActions('status', ['gettimeshareAdmin']),
38
+    ...mapActions('myWeeks', ['getItems']),
39
+    onEdit(item) {
40
+      this.$router.push(`/timeshare/${item.id}`);
41
+    },
38 42
   },
39 43
 };
40 44
 </script>

+ 1
- 0
src/components/communication/templateDetail.vue View File

@@ -174,6 +174,7 @@
174 174
             :hideSearch="true"
175 175
             :showNew="false"
176 176
             :deleteable="CanEdit"
177
+            :allowMultipleSelect="true"
177 178
             @onDelete="onItemDelete"
178 179
           />
179 180
         </div>

+ 3
- 1
src/components/communication/templatePage.vue View File

@@ -57,7 +57,9 @@ export default {
57 57
   methods: {
58 58
     ...mapActions('template', ['getList']),
59 59
     onRowClick(item) {
60
-      this.detailItem = item;
60
+      if (this.detailItem !== item) {
61
+        this.detailItem = item;
62
+      } else this.detailItem = undefined;
61 63
       this.clickedNew = false;
62 64
     },
63 65
     onNew() {

+ 33
- 5
src/components/shared/listView.vue View File

@@ -10,8 +10,8 @@
10 10
         <div class="btn btn-primary myBackground" @click="onNew()">New</div>
11 11
       </div>
12 12
     </div>
13
-    <div v-if="items && items.length > 0">
14
-      <table id="table" class="table table-bordered table-hover">
13
+    <div v-if="items && items.length > 0" class="table-responsive">
14
+      <table id="table" class="table table-sm table-bordered table-hover">
15 15
         <thead>
16 16
           <tr class="dnd-moved">
17 17
             <th v-for="(column, c) in Columns" :key="c">
@@ -25,8 +25,8 @@
25 25
           <tr
26 26
             v-for="(item, i) in DisplayItems"
27 27
             :key="i"
28
-            class="text-left dnd-moved"
29
-            @click="onRowClick(item)"
28
+            @click="onRowClick(item, i)"
29
+            :class="{'selected': isSelected(i), 'cursor-pointer': allowSelect}"
30 30
           >
31 31
             <td
32 32
               v-for="(column, c) in Columns"
@@ -96,6 +96,12 @@ export default {
96 96
     }
97 97
   },
98 98
   props: {
99
+    allowSelect: {
100
+      default: true,
101
+    },
102
+    allowMultipleSelect: {
103
+      default: false,
104
+    },
99 105
     hideSearch: {
100 106
       default: false,
101 107
     },
@@ -115,6 +121,7 @@ export default {
115 121
   },
116 122
   data() {
117 123
     return {
124
+      selectedItems: [],
118 125
       showControl: false,
119 126
       sortKey: '',
120 127
       reverse: false,
@@ -125,6 +132,9 @@ export default {
125 132
     };
126 133
   },
127 134
   methods: {
135
+    isSelected(i) {
136
+      return _.some(this.selectedItems, x => x === i);
137
+    },
128 138
     onNew() {
129 139
       this.$emit('onNew');
130 140
     },
@@ -137,7 +147,15 @@ export default {
137 147
     onDelete(item) {
138 148
       this.$emit('onDelete', item);
139 149
     },
140
-    onRowClick(item) {
150
+    onRowClick(item, i) {
151
+      if (_.some(this.selectedItems, x => x === i)) {
152
+        this.selectedItems = this.selectedItems.filter(value => value !== i);
153
+      } else {
154
+        if (!this.allowMultipleSelect) {
155
+          this.selectedItems = [];
156
+        }
157
+        this.selectedItems.push(i);
158
+      }
141 159
       this.$emit('onRowClick', item);
142 160
     },
143 161
     changeColumn(title, checked) {
@@ -257,4 +275,14 @@ th[draggable] a {
257 275
 .over {
258 276
   background-color: rgba(0, 0, 255, 0.35);
259 277
 }
278
+.my-border {
279
+  border: solid 3px silver;
280
+}
281
+.selected {
282
+  background-color: rgba(96, 203, 235, 0.5);
283
+  border: white 2px double;
284
+}
285
+.selected:hover {
286
+  background-color: rgba(96, 203, 235, 0.85);
287
+}
260 288
 </style>

+ 6
- 0
src/components/shared/navBar.vue View File

@@ -144,6 +144,11 @@
144 144
                   class="dropdown-item cursor-pointer"
145 145
                   @click="routerGoTo('/unitConfiguration/list')"
146 146
                 >Unit Configuration</a>
147
+                <a
148
+                  class="dropdown-item cursor-pointer"
149
+                  @click="routerGoTo('/communication/template')"
150
+                >Templates</a>
151
+                <hr />
147 152
                 <a
148 153
                   class="dropdown-item cursor-pointer"
149 154
                   @click="routerGoTo('/status/userManagementPage')"
@@ -160,6 +165,7 @@
160 165
                   class="dropdown-item cursor-pointer"
161 166
                   @click="routerGoTo('/propertyTypes/list')"
162 167
                 >Property Types</a>
168
+                <hr />
163 169
                 <a
164 170
                   class="dropdown-item cursor-pointer"
165 171
                   @click="routerGoTo('/searchLog')"

Loading…
Cancel
Save