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
 <template>
1
 <template>
2
-  <!-- <section class="intro-single"> -->
3
-  <div class="container">
2
+  <div>
3
+    <br />
4
     <br />
4
     <br />
5
     <br />
5
     <br />
6
     <br />
6
     <br />
7
     <br />
7
     <br />
8
     <div class="row">
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
       </div>
11
       </div>
18
     </div>
12
     </div>
19
-    <div id="table" class="col-xs-12 table-responsive">
20
-      <datatable :columns="columns" :data="rows"></datatable>
21
-    </div>
22
   </div>
13
   </div>
23
-  <!-- </section> -->
24
 </template>
14
 </template>
25
 <script>
15
 <script>
26
 import { mapState, mapActions } from 'vuex';
16
 import { mapState, mapActions } from 'vuex';
17
+import Log from '../../../assets/Log';
18
+import ListView from '../../shared/listView.vue';
27
 
19
 
28
 export default {
20
 export default {
29
   name: 'TimeshareAdmin',
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
   computed: {
34
   computed: {
34
-    ...mapState('status', ['timeshareAdmin']),
35
+    ...mapState('myWeeks', ['items']),
35
   },
36
   },
36
   methods: {
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
 </script>
44
 </script>

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

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

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

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

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

10
         <div class="btn btn-primary myBackground" @click="onNew()">New</div>
10
         <div class="btn btn-primary myBackground" @click="onNew()">New</div>
11
       </div>
11
       </div>
12
     </div>
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
         <thead>
15
         <thead>
16
           <tr class="dnd-moved">
16
           <tr class="dnd-moved">
17
             <th v-for="(column, c) in Columns" :key="c">
17
             <th v-for="(column, c) in Columns" :key="c">
25
           <tr
25
           <tr
26
             v-for="(item, i) in DisplayItems"
26
             v-for="(item, i) in DisplayItems"
27
             :key="i"
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
             <td
31
             <td
32
               v-for="(column, c) in Columns"
32
               v-for="(column, c) in Columns"
96
     }
96
     }
97
   },
97
   },
98
   props: {
98
   props: {
99
+    allowSelect: {
100
+      default: true,
101
+    },
102
+    allowMultipleSelect: {
103
+      default: false,
104
+    },
99
     hideSearch: {
105
     hideSearch: {
100
       default: false,
106
       default: false,
101
     },
107
     },
115
   },
121
   },
116
   data() {
122
   data() {
117
     return {
123
     return {
124
+      selectedItems: [],
118
       showControl: false,
125
       showControl: false,
119
       sortKey: '',
126
       sortKey: '',
120
       reverse: false,
127
       reverse: false,
125
     };
132
     };
126
   },
133
   },
127
   methods: {
134
   methods: {
135
+    isSelected(i) {
136
+      return _.some(this.selectedItems, x => x === i);
137
+    },
128
     onNew() {
138
     onNew() {
129
       this.$emit('onNew');
139
       this.$emit('onNew');
130
     },
140
     },
137
     onDelete(item) {
147
     onDelete(item) {
138
       this.$emit('onDelete', item);
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
       this.$emit('onRowClick', item);
159
       this.$emit('onRowClick', item);
142
     },
160
     },
143
     changeColumn(title, checked) {
161
     changeColumn(title, checked) {
257
 .over {
275
 .over {
258
   background-color: rgba(0, 0, 255, 0.35);
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
 </style>
288
 </style>

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

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

Loading…
Cancel
Save