vue-laravel-crud 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@
2
2
  import draggable from "vuedraggable";
3
3
  import axios from "axios";
4
4
  import moment from "moment";
5
+ import { Model, Collection } from 'vue-mc';
5
6
 
6
7
  export default /*#__PURE__*/ {
7
8
  name: "VueLaravelCrud",
@@ -37,6 +38,8 @@ export default /*#__PURE__*/ {
37
38
  MODE_CARDS: 2,
38
39
  MODE_CUSTOM: 3,
39
40
  },
41
+ useMc: false,
42
+ collection
40
43
  };
41
44
  },
42
45
  watch: {
@@ -258,14 +261,21 @@ export default /*#__PURE__*/ {
258
261
  },
259
262
 
260
263
  mounted() {
261
- this.item = this.model;
262
- this.itemDefault = JSON.parse(JSON.stringify(this.item));
264
+
265
+ if (this.model instanceof Model) {
266
+ this.useMc = true;
267
+ this.collection = new Collection();
268
+ } else {
269
+ this.item = this.model;
270
+ this.itemDefault = JSON.parse(JSON.stringify(this.item));
271
+ }
272
+
263
273
  this.internalFilters = [];
264
274
  this.setupFilters();
265
275
 
266
- if(this.ajax){
276
+ if (this.ajax) {
267
277
  this.fetchItems();
268
- }else{
278
+ } else {
269
279
  this.items = this.models;
270
280
  this.pagination.total = this.items.length;
271
281
  }
@@ -290,9 +300,9 @@ export default /*#__PURE__*/ {
290
300
  },
291
301
 
292
302
  itemsList() {
293
- if(this.ajax) {
303
+ if (this.ajax) {
294
304
  return this.items;
295
- }else{
305
+ } else {
296
306
  return this.items.slice(this.paginationIndexStart, this.paginationIndexEnd);
297
307
  }
298
308
  },
@@ -450,12 +460,12 @@ export default /*#__PURE__*/ {
450
460
  this.selectedItems.push(this.item);
451
461
  }
452
462
  },
453
- externalUpdate(itemsUpdate,addIfNotExist = true,key= 'id'){
463
+ externalUpdate(itemsUpdate, addIfNotExist = true, key = 'id') {
454
464
  itemsUpdate.forEach(itemUpdate => {
455
465
  let itemInList = this.items.find(item => item[key] === itemUpdate[key]);
456
466
  if (itemInList) Object.assign(itemInList, itemUpdate);
457
467
  else {
458
- if(addIfNotExist){
468
+ if (addIfNotExist) {
459
469
  this.items.push(itemUpdate);
460
470
  }
461
471
  }
@@ -497,7 +507,7 @@ export default /*#__PURE__*/ {
497
507
 
498
508
  refresh() {
499
509
  this.$emit("refresh", {});
500
- if(!this.ajax){
510
+ if (!this.ajax) {
501
511
  return;
502
512
  }
503
513
  this.fetchItems(this.pagination.current_page);
@@ -513,11 +523,27 @@ export default /*#__PURE__*/ {
513
523
  this.refresh();
514
524
  }, 1);
515
525
  },
526
+
527
+ fetchItemsMc(page = 1) {
528
+ this.loading = true;
529
+ this.$emit("beforeFetch", {});
530
+ this.collection.page(page).fetch().then((response) => {
531
+ console.debug("fetch page ",page,response,this.collection);
532
+ this.loading = false;
533
+ this.$emit("afterFetch", {});
534
+ }).catch((error) => {
535
+ this.toastError(error);
536
+ this.loading = false;
537
+ });
538
+ },
516
539
  fetchItems(page = 1) {
517
- if(!this.ajax){
540
+ if (!this.ajax) {
518
541
  return;
519
542
  }
520
543
  this.$emit("beforeFetch", {});
544
+ if (this.useMc) {
545
+ return this.fetchItemsMc(page);
546
+ }
521
547
  this.loading = true;
522
548
  axios
523
549
  .get(this.apiUrl + "/" + this.modelName, {
@@ -563,7 +589,7 @@ export default /*#__PURE__*/ {
563
589
  }
564
590
 
565
591
  this.loading = false;
566
- this.$emit("afterFetch", {});
592
+ this.$emit("afterFetch", {});
567
593
  })
568
594
  .catch((error) => {
569
595
  //console.debug(error);
@@ -587,12 +613,12 @@ export default /*#__PURE__*/ {
587
613
  this.loading = true;
588
614
  axios
589
615
  .delete(this.apiUrl + "/" + this.modelName + "/" + id)
590
- .then( (response) => {
616
+ .then((response) => {
591
617
  this.items.splice(index, 1);
592
618
  this.toastSuccess("Elemento eliminado.");
593
619
  this.loading = false;
594
620
  })
595
- .catch( (error) => {
621
+ .catch((error) => {
596
622
  this.toastError(error);
597
623
  this.loading = false;
598
624
  });
@@ -616,13 +642,13 @@ export default /*#__PURE__*/ {
616
642
  .post(this.apiUrl + "/" + this.modelName + "/sort", {
617
643
  order: order,
618
644
  })
619
- .then( (response) => {
645
+ .then((response) => {
620
646
  let data = response.data;
621
647
  this.toastSuccess("Orden Actualizado");
622
648
  if (this.refreshAfterSave) this.refresh();
623
649
  this.loading = false;
624
650
  })
625
- .catch( (error) => {
651
+ .catch((error) => {
626
652
  //console.debug(error);
627
653
  this.toastError(error);
628
654
  this.loading = false;
@@ -688,7 +714,7 @@ export default /*#__PURE__*/ {
688
714
  this.item
689
715
  )
690
716
  .then((response) => {
691
- if(this.hideModalAfterSave){
717
+ if (this.hideModalAfterSave) {
692
718
  this.$bvModal.hide("modal-form-item-" + this.modelName);
693
719
  }
694
720
 
@@ -725,9 +751,9 @@ export default /*#__PURE__*/ {
725
751
 
726
752
  axios
727
753
  .post(this.apiUrl + "/" + this.modelName, formData)
728
- .then( (response) => {
754
+ .then((response) => {
729
755
  this.loading = false;
730
- if(this.hideModalAfterSave){
756
+ if (this.hideModalAfterSave) {
731
757
  this.$bvModal.hide("modal-form-item-" + this.modelName);
732
758
  }
733
759
  if (response.data.success) {
@@ -744,16 +770,16 @@ export default /*#__PURE__*/ {
744
770
  if (this.refreshAfterSave) this.refresh();
745
771
  this.toastSuccess("Elemento Creado");
746
772
  })
747
- .catch( (error) => {
773
+ .catch((error) => {
748
774
  this.toastError(error);
749
775
  this.loading = false;
750
776
  });
751
777
  } else {
752
778
  axios
753
779
  .post(this.apiUrl + "/" + this.modelName, this.item)
754
- .then( (response) => {
780
+ .then((response) => {
755
781
  this.loading = false;
756
- if(this.hideModalAfterSave){
782
+ if (this.hideModalAfterSave) {
757
783
  this.$bvModal.hide("modal-form-item-" + this.modelName);
758
784
  }
759
785
  if (response.data.success) {
@@ -770,7 +796,7 @@ export default /*#__PURE__*/ {
770
796
  if (this.refreshAfterSave) this.refresh();
771
797
  this.toastSuccess("Elemento Creado");
772
798
  })
773
- .catch( (error) => {
799
+ .catch((error) => {
774
800
  this.toastError(error);
775
801
  this.loading = false;
776
802
  });
@@ -852,32 +878,18 @@ export default /*#__PURE__*/ {
852
878
  <h4 class="crud-title" v-if="showTitle">{{ title }}</h4>
853
879
 
854
880
  <b-sidebar v-model="filterSidebarOpen" title="Filtrar" right shadow>
855
- <slot
856
- name="sidebarFilters"
857
- v-bind:createItem="createItem"
858
- v-bind:toggleDisplayMode="toggleDisplayMode"
859
- v-bind:loading="loading"
860
- v-bind:isColumnHasFilter="isColumnHasFilter"
861
- v-bind:setFilter="setFilter"
862
- >
881
+ <slot name="sidebarFilters" v-bind:createItem="createItem" v-bind:toggleDisplayMode="toggleDisplayMode"
882
+ v-bind:loading="loading" v-bind:isColumnHasFilter="isColumnHasFilter" v-bind:setFilter="setFilter">
863
883
  <div class="px-3 py-2">
864
884
  <div v-for="(column, indexc) in columns" :key="indexc">
865
885
  <div v-if="isColumnHasFilter(column)">
866
- <slot
867
- :name="'sidebar-filter-' + column.prop"
868
- v-bind:column="column"
869
- v-bind:filter="filter"
870
- v-bind:internalFilterByProp="internalFilterByProp"
871
- v-if="internalFilterByProp(column.prop)"
872
- >
886
+ <slot :name="'sidebar-filter-' + column.prop" v-bind:column="column" v-bind:filter="filter"
887
+ v-bind:internalFilterByProp="internalFilterByProp" v-if="internalFilterByProp(column.prop)">
873
888
  <div class="form-group" v-if="column.type == 'boolean'">
874
889
  <label>{{ column.label }}</label>
875
890
 
876
- <select
877
- class="form-control"
878
- v-model="internalFilterByProp(column.prop).value"
879
- @change="onChangeFilter($event)"
880
- >
891
+ <select class="form-control" v-model="internalFilterByProp(column.prop).value"
892
+ @change="onChangeFilter($event)">
881
893
  <option value=""></option>
882
894
  <option value="1">Sí</option>
883
895
  <option value="0">No</option>
@@ -886,26 +898,14 @@ export default /*#__PURE__*/ {
886
898
  <div class="form-group" v-else-if="column.type == 'date'">
887
899
  <div class="row">
888
900
  <div class="col-6">
889
- <b-form-datepicker
890
- v-model="
891
- internalFilterByProp(column.prop + '_from').value
892
- "
893
- today-button
894
- reset-button
895
- close-button
896
- locale="es"
897
- ></b-form-datepicker>
901
+ <b-form-datepicker v-model="
902
+ internalFilterByProp(column.prop + '_from').value
903
+ " today-button reset-button close-button locale="es"></b-form-datepicker>
898
904
  </div>
899
905
  <div class="col-6">
900
- <b-form-datepicker
901
- v-model="
902
- internalFilterByProp(column.prop + '_to').value
903
- "
904
- today-button
905
- reset-button
906
- close-button
907
- locale="es"
908
- ></b-form-datepicker>
906
+ <b-form-datepicker v-model="
907
+ internalFilterByProp(column.prop + '_to').value
908
+ " today-button reset-button close-button locale="es"></b-form-datepicker>
909
909
  </div>
910
910
  </div>
911
911
  </div>
@@ -914,21 +914,14 @@ export default /*#__PURE__*/ {
914
914
  <label>{{ column.label }}</label>
915
915
  <div class="d-none">{{ column.options }}</div>
916
916
 
917
- <select
918
- class="form-control"
919
- v-model="internalFilterByProp(column.prop).value"
920
- @change="onChangeFilter($event)"
921
- >
917
+ <select class="form-control" v-model="internalFilterByProp(column.prop).value"
918
+ @change="onChangeFilter($event)">
922
919
  <option value=""></option>
923
- <option
924
- :value="option.id"
925
- v-for="option in column.options"
926
- :key="option.id"
927
- >
920
+ <option :value="option.id" v-for="option in column.options" :key="option.id">
928
921
  {{
929
922
  option.text
930
- ? option.text
931
- : option.label
923
+ ? option.text
924
+ : option.label
932
925
  ? option.label
933
926
  : ""
934
927
  }}
@@ -940,22 +933,15 @@ export default /*#__PURE__*/ {
940
933
  <label>{{ column.label }}</label>
941
934
  <div class="d-none">{{ column.options }}</div>
942
935
 
943
- <select
944
- class="form-control"
945
- v-model="internalFilterByProp(column.prop).value"
946
- @change="onChangeFilter($event)"
947
- >
936
+ <select class="form-control" v-model="internalFilterByProp(column.prop).value"
937
+ @change="onChangeFilter($event)">
948
938
  <option value=""></option>
949
939
  <template v-if="column.options">
950
- <option
951
- :value="option.id"
952
- v-for="option in column.options"
953
- :key="option.id"
954
- >
940
+ <option :value="option.id" v-for="option in column.options" :key="option.id">
955
941
  {{
956
942
  option.text
957
- ? option.text
958
- : option.label
943
+ ? option.text
944
+ : option.label
959
945
  ? option.label
960
946
  : ""
961
947
  }}
@@ -967,11 +953,8 @@ export default /*#__PURE__*/ {
967
953
  <div class="form-group" v-else>
968
954
  <label>{{ column.label }}</label>
969
955
 
970
- <input
971
- class="form-control"
972
- v-model.lazy="internalFilterByProp(column.prop).value"
973
- @change="onChangeFilter($event)"
974
- />
956
+ <input class="form-control" v-model.lazy="internalFilterByProp(column.prop).value"
957
+ @change="onChangeFilter($event)" />
975
958
  </div>
976
959
  </slot>
977
960
  </div>
@@ -991,63 +974,30 @@ export default /*#__PURE__*/ {
991
974
 
992
975
  <div class="table-options">
993
976
  <b-button-group class="mr-1">
994
- <slot
995
- name="tableActions"
996
- v-bind:createItem="createItem"
997
- v-bind:toggleDisplayMode="toggleDisplayMode"
998
- v-bind:loading="loading"
999
- >
977
+ <slot name="tableActions" v-bind:createItem="createItem" v-bind:toggleDisplayMode="toggleDisplayMode"
978
+ v-bind:loading="loading">
1000
979
  <slot name="tableActionsPrepend" v-bind:loading="loading"> </slot>
1001
- <b-button
1002
- variant="success"
1003
- v-if="showCreateBtn"
1004
- @click="createItem()"
1005
- :disabled="loading"
1006
- >
980
+ <b-button variant="success" v-if="showCreateBtn" @click="createItem()" :disabled="loading">
1007
981
  <b-icon-plus></b-icon-plus>{{ messageNew }}
1008
982
  </b-button>
1009
983
 
1010
- <b-button v-if="enableFilters" @click="toggleFilters()"
1011
- >Filtros</b-button
1012
- >
1013
-
1014
- <b-button @click="refresh()"
1015
- ><b-icon-arrow-clockwise></b-icon-arrow-clockwise
1016
- ></b-button>
1017
-
1018
- <b-button
1019
- variant="info"
1020
- @click="toggleDisplayMode()"
1021
- :disabled="loading"
1022
- v-if="displayModeToggler"
1023
- >
1024
- <b-icon-card-list
1025
- v-if="displayMode == displayModes.MODE_TABLE"
1026
- ></b-icon-card-list>
1027
- <b-icon-table
1028
- v-if="displayMode == displayModes.MODE_CARDS"
1029
- ></b-icon-table>
984
+ <b-button v-if="enableFilters" @click="toggleFilters()">Filtros</b-button>
985
+
986
+ <b-button @click="refresh()"><b-icon-arrow-clockwise></b-icon-arrow-clockwise></b-button>
987
+
988
+ <b-button variant="info" @click="toggleDisplayMode()" :disabled="loading" v-if="displayModeToggler">
989
+ <b-icon-card-list v-if="displayMode == displayModes.MODE_TABLE"></b-icon-card-list>
990
+ <b-icon-table v-if="displayMode == displayModes.MODE_CARDS"></b-icon-table>
1030
991
  </b-button>
1031
992
 
1032
993
  <div class="crud-search m-0" v-if="showSearch">
1033
994
  <b-input-group>
1034
995
  <b-input-group-prepend>
1035
- <b-button
1036
- variant="info"
1037
- @click="displaySearch = !displaySearch"
1038
- :class="{ open: displaySearch }"
1039
- ><b-icon-search></b-icon-search
1040
- ></b-button>
996
+ <b-button variant="info" @click="displaySearch = !displaySearch"
997
+ :class="{ open: displaySearch }"><b-icon-search></b-icon-search></b-button>
1041
998
  </b-input-group-prepend>
1042
- <b-form-input
1043
- v-if="displaySearch"
1044
- v-model="search"
1045
- class="pl-2"
1046
- type="search"
1047
- required
1048
- :placeholder="searchPlaceholder"
1049
- debounce="500"
1050
- ></b-form-input>
999
+ <b-form-input v-if="displaySearch" v-model="search" class="pl-2" type="search" required
1000
+ :placeholder="searchPlaceholder" debounce="500"></b-form-input>
1051
1001
  </b-input-group>
1052
1002
 
1053
1003
  <slot name="tableActionsAppend" v-bind:loading="loading"> </slot>
@@ -1057,38 +1007,22 @@ export default /*#__PURE__*/ {
1057
1007
  </div>
1058
1008
  </div>
1059
1009
  <b-overlay :show="loading" rounded="sm">
1060
- <div
1061
- :class="['table-responsive', tableContainerClass]"
1062
- v-if="displayMode == displayModes.MODE_TABLE"
1063
- >
1010
+ <div :class="['table-responsive', tableContainerClass]" v-if="displayMode == displayModes.MODE_TABLE">
1064
1011
  <table :class="['table table-hover table-striped w-100', tableClass]">
1065
1012
  <thead class="thead-light">
1066
1013
  <tr>
1067
1014
  <slot name="rowHead">
1068
- <th
1069
- v-for="(column, indexc) in columns"
1070
- :key="indexc"
1071
- :style="{ width: column.width ? column.width : 'inherit' }"
1072
- scope="col"
1073
- >
1074
- <slot
1075
- :name="'filter-' + column.prop"
1076
- v-bind:column="column"
1077
- v-bind:filter="filter"
1078
- v-bind:internalFilterByProp="internalFilterByProp"
1079
- v-if="
1015
+ <th v-for="(column, indexc) in columns" :key="indexc"
1016
+ :style="{ width: column.width ? column.width : 'inherit' }" scope="col">
1017
+ <slot :name="'filter-' + column.prop" v-bind:column="column" v-bind:filter="filter"
1018
+ v-bind:internalFilterByProp="internalFilterByProp" v-if="
1080
1019
  enableFilters &&
1081
1020
  filtersVisible &&
1082
1021
  isColumnHasFilter(column) &&
1083
1022
  internalFilterByProp(column.prop)
1084
- "
1085
- >
1086
- <select
1087
- v-if="column.type == 'boolean'"
1088
- class="form-control"
1089
- v-model="internalFilterByProp(column.prop).value"
1090
- @change="onChangeFilter($event)"
1091
- >
1023
+ ">
1024
+ <select v-if="column.type == 'boolean'" class="form-control"
1025
+ v-model="internalFilterByProp(column.prop).value" @change="onChangeFilter($event)">
1092
1026
  <option value="">{{ column.label }}</option>
1093
1027
  <option value="1">Sí</option>
1094
1028
  <option value="0">No</option>
@@ -1096,133 +1030,72 @@ export default /*#__PURE__*/ {
1096
1030
 
1097
1031
  <div class="row" v-else-if="column.type == 'date'">
1098
1032
  <div class="col-6">
1099
- <b-form-datepicker
1100
- v-model="
1101
- internalFilterByProp(column.prop + '_from').value
1102
- "
1103
- today-button
1104
- reset-button
1105
- close-button
1106
- locale="es"
1107
- ></b-form-datepicker>
1033
+ <b-form-datepicker v-model="
1034
+ internalFilterByProp(column.prop + '_from').value
1035
+ " today-button reset-button close-button locale="es"></b-form-datepicker>
1108
1036
  </div>
1109
1037
  <div class="col-6">
1110
- <b-form-datepicker
1111
- v-model="
1112
- internalFilterByProp(column.prop + '_to').value
1113
- "
1114
- today-button
1115
- reset-button
1116
- close-button
1117
- locale="es"
1118
- ></b-form-datepicker>
1038
+ <b-form-datepicker v-model="
1039
+ internalFilterByProp(column.prop + '_to').value
1040
+ " today-button reset-button close-button locale="es"></b-form-datepicker>
1119
1041
  </div>
1120
1042
  </div>
1121
1043
 
1122
- <select
1123
- v-else-if="column.type == 'state'"
1124
- class="form-control"
1125
- v-model="internalFilterByProp(column.prop).value"
1126
- @change="onChangeFilter($event)"
1127
- >
1044
+ <select v-else-if="column.type == 'state'" class="form-control"
1045
+ v-model="internalFilterByProp(column.prop).value" @change="onChangeFilter($event)">
1128
1046
  <option value="">{{ column.label }}</option>
1129
- <option
1130
- :value="option.id"
1131
- v-for="(option, indexo) in column.options"
1132
- :key="indexo"
1133
- >
1047
+ <option :value="option.id" v-for="(option, indexo) in column.options" :key="indexo">
1134
1048
  {{
1135
1049
  option.text
1136
- ? option.text
1137
- : option.label
1050
+ ? option.text
1051
+ : option.label
1138
1052
  ? option.label
1139
1053
  : ""
1140
1054
  }}
1141
1055
  </option>
1142
1056
  </select>
1143
1057
 
1144
- <select
1145
- v-else-if="column.type == 'array'"
1146
- class="form-control"
1147
- v-model="internalFilterByProp(column.prop).value"
1148
- @change="onChangeFilter($event)"
1149
- >
1058
+ <select v-else-if="column.type == 'array'" class="form-control"
1059
+ v-model="internalFilterByProp(column.prop).value" @change="onChangeFilter($event)">
1150
1060
  <option value="">{{ column.label }}</option>
1151
- <option
1152
- :value="option.id"
1153
- v-for="(option, indexo) in column.options"
1154
- :key="indexo"
1155
- >
1061
+ <option :value="option.id" v-for="(option, indexo) in column.options" :key="indexo">
1156
1062
  {{
1157
1063
  option.text
1158
- ? option.text
1159
- : option.label
1064
+ ? option.text
1065
+ : option.label
1160
1066
  ? option.label
1161
1067
  : ""
1162
1068
  }}
1163
1069
  </option>
1164
1070
  </select>
1165
1071
 
1166
- <b-form-checkbox
1167
- v-else-if="column.type == 'checkbox'"
1168
- name="select-all"
1169
- @change="toggleAll()"
1170
- >
1072
+ <b-form-checkbox v-else-if="column.type == 'checkbox'" name="select-all" @change="toggleAll()">
1171
1073
  </b-form-checkbox>
1172
- <input
1173
- v-else
1174
- class="form-control"
1175
- v-model="internalFilterByProp(column.prop).value"
1176
- :placeholder="column.label"
1177
- @change="onChangeFilter($event)"
1178
- />
1074
+ <input v-else class="form-control" v-model="internalFilterByProp(column.prop).value"
1075
+ :placeholder="column.label" @change="onChangeFilter($event)" />
1179
1076
  </slot>
1180
1077
 
1181
1078
  <span v-else>{{ column.label }}</span>
1182
1079
 
1183
- <span
1184
- v-if="
1185
- sortable && internalFilterByProp(column.prop + '_sort')
1186
- "
1187
- class="sort-filter"
1188
- @click="toggleSortFilter(column)"
1189
- ><b-icon-sort
1190
- v-if="!internalFilterByProp(column.prop + '_sort').value"
1191
- ></b-icon-sort
1192
- ><b-icon-sort-up
1193
- v-if="
1080
+ <span v-if="
1081
+ sortable && internalFilterByProp(column.prop + '_sort')
1082
+ " class="sort-filter" @click="toggleSortFilter(column)"><b-icon-sort
1083
+ v-if="!internalFilterByProp(column.prop + '_sort').value"></b-icon-sort><b-icon-sort-up v-if="
1194
1084
  internalFilterByProp(column.prop + '_sort').value ==
1195
1085
  'ASC'
1196
- "
1197
- ></b-icon-sort-up
1198
- ><b-icon-sort-down
1199
- v-if="
1200
- internalFilterByProp(column.prop + '_sort').value ==
1201
- 'DESC'
1202
- "
1203
- ></b-icon-sort-down
1204
- ></span>
1086
+ "></b-icon-sort-up><b-icon-sort-down v-if="
1087
+ internalFilterByProp(column.prop + '_sort').value ==
1088
+ 'DESC'
1089
+ "></b-icon-sort-down></span>
1205
1090
  </th>
1206
1091
  </slot>
1207
1092
  </tr>
1208
1093
  </thead>
1209
1094
 
1210
- <draggable
1211
- v-model="items"
1212
- group="people"
1213
- tag="tbody"
1214
- :draggable="orderable ? '.item' : '.none'"
1215
- @start="drag = true"
1216
- @end="drag = false"
1217
- @sort="onSort()"
1218
- >
1219
- <tr
1220
- v-for="(item, index) in items"
1221
- v-bind:key="index"
1222
- @mouseover="onRowHover(item, index)"
1223
- @click="onRowClick(item, index)"
1224
- class="item"
1225
- >
1095
+ <draggable v-model="items" group="people" tag="tbody" :draggable="orderable ? '.item' : '.none'"
1096
+ @start="drag = true" @end="drag = false" @sort="onSort()">
1097
+ <tr v-for="(item, index) in items" v-bind:key="index" @mouseover="onRowHover(item, index)"
1098
+ @click="onRowClick(item, index)" class="item">
1226
1099
  <template v-if="item.group">
1227
1100
  <th :colspan="columns.length">
1228
1101
  <span>{{ item.label }}</span>
@@ -1230,52 +1103,32 @@ export default /*#__PURE__*/ {
1230
1103
  </template>
1231
1104
  <template v-else>
1232
1105
  <slot name="row" v-bind:item="item">
1233
- <td
1234
- v-for="(column, indexc) in columns"
1235
- :key="indexc"
1236
- :scope="column.prop == 'id' ? 'row' : ''"
1237
- >
1238
- <slot
1239
- :name="'cell-' + column.prop"
1240
- v-bind:item="item"
1241
- v-bind:index="index"
1242
- v-bind:itemindex="index"
1243
- v-bind:columnindex="indexc"
1244
- >
1106
+ <td v-for="(column, indexc) in columns" :key="indexc" :scope="column.prop == 'id' ? 'row' : ''">
1107
+ <slot :name="'cell-' + column.prop" v-bind:item="item" v-bind:index="index" v-bind:itemindex="index"
1108
+ v-bind:columnindex="indexc">
1245
1109
  <span v-if="column.type == 'boolean'">
1246
- <b-badge
1247
- variant="success"
1248
- v-if="
1249
- itemValue(column, item) == 'true' ||
1250
- itemValue(column, item) == 1 ||
1251
- itemValue(column, item) == '1'
1252
- "
1253
- ><b-icon-check-circle></b-icon-check-circle
1254
- ></b-badge>
1255
- <b-badge
1256
- variant="danger"
1257
- v-if="
1258
- !itemValue(column, item) ||
1259
- itemValue(column, item) == '0' ||
1260
- itemValue(column, item) == 'false'
1261
- "
1262
- ><b-icon-x-circle></b-icon-x-circle
1263
- ></b-badge>
1110
+ <b-badge variant="success" v-if="
1111
+ itemValue(column, item) == 'true' ||
1112
+ itemValue(column, item) == 1 ||
1113
+ itemValue(column, item) == '1'
1114
+ "><b-icon-check-circle></b-icon-check-circle></b-badge>
1115
+ <b-badge variant="danger" v-if="
1116
+ !itemValue(column, item) ||
1117
+ itemValue(column, item) == '0' ||
1118
+ itemValue(column, item) == 'false'
1119
+ "><b-icon-x-circle></b-icon-x-circle></b-badge>
1264
1120
  </span>
1265
1121
  <span v-else-if="column.type == 'date'">
1266
1122
  {{
1267
1123
  itemValue(column, item) && column.format
1268
- ? moment(itemValue(column, item)).format(
1269
- column.format
1270
- )
1271
- : itemValue(column, item)
1124
+ ? moment(itemValue(column, item)).format(
1125
+ column.format
1126
+ )
1127
+ : itemValue(column, item)
1272
1128
  }}
1273
1129
  </span>
1274
1130
  <span v-else-if="column.type == 'checkbox'">
1275
- <b-form-checkbox
1276
- v-model="item.selected"
1277
- @change="onCheckSelect($event, item)"
1278
- >
1131
+ <b-form-checkbox v-model="item.selected" @change="onCheckSelect($event, item)">
1279
1132
  </b-form-checkbox>
1280
1133
  </span>
1281
1134
 
@@ -1300,30 +1153,15 @@ export default /*#__PURE__*/ {
1300
1153
  </slot>
1301
1154
 
1302
1155
  <b-button-group v-if="column.type == 'actions'">
1303
- <slot
1304
- name="rowAction"
1305
- v-bind:item="item"
1306
- v-bind:index="index"
1307
- v-bind:showItem="showItem"
1308
- v-bind:updateItem="updateItem"
1309
- v-bind:removeItem="removeItem"
1310
- >
1311
- <b-button
1312
- variant="primary"
1313
- @click="showItem(item.id, index)"
1314
- >
1156
+ <slot name="rowAction" v-bind:item="item" v-bind:index="index" v-bind:showItem="showItem"
1157
+ v-bind:updateItem="updateItem" v-bind:removeItem="removeItem">
1158
+ <b-button variant="primary" @click="showItem(item.id, index)">
1315
1159
  <b-icon-eye></b-icon-eye>
1316
1160
  </b-button>
1317
- <b-button
1318
- variant="secondary"
1319
- @click="updateItem(item.id, index)"
1320
- >
1161
+ <b-button variant="secondary" @click="updateItem(item.id, index)">
1321
1162
  <b-icon-pencil></b-icon-pencil>
1322
1163
  </b-button>
1323
- <b-button
1324
- variant="danger"
1325
- @click="removeItem(item.id, index)"
1326
- >
1164
+ <b-button variant="danger" @click="removeItem(item.id, index)">
1327
1165
  <b-icon-trash></b-icon-trash>
1328
1166
  </b-button>
1329
1167
  </slot>
@@ -1344,62 +1182,28 @@ export default /*#__PURE__*/ {
1344
1182
  {{ messageEmptyResults }}
1345
1183
  </p>
1346
1184
 
1347
- <draggable
1348
- v-model="items"
1349
- group="people"
1350
- class="row"
1351
- :draggable="orderable ? '.item' : '.none'"
1352
- @start="drag = true"
1353
- @end="drag = false"
1354
- @sort="onSort()"
1355
- >
1356
- <b-col
1357
- v-for="(item, index) in items"
1358
- v-bind:key="index"
1359
- :cols="colXs"
1360
- :sm="colSm"
1361
- :md="colMd"
1362
- :lg="colLg"
1363
- :xl="colXl"
1364
- class="item"
1365
- >
1366
- <b-card
1367
- :title="item.title"
1368
- tag="article"
1369
- class="mb-2 card-crud"
1370
- :class="cardClass"
1371
- :hideFooter="cardHideFooter"
1372
- >
1185
+ <draggable v-model="items" group="people" class="row" :draggable="orderable ? '.item' : '.none'"
1186
+ @start="drag = true" @end="drag = false" @sort="onSort()">
1187
+ <b-col v-for="(item, index) in items" v-bind:key="index" :cols="colXs" :sm="colSm" :md="colMd" :lg="colLg"
1188
+ :xl="colXl" class="item">
1189
+ <b-card :title="item.title" tag="article" class="mb-2 card-crud" :class="cardClass"
1190
+ :hideFooter="cardHideFooter">
1373
1191
  <slot name="card" v-bind:item="item">
1374
1192
  <div v-for="(column, indexc) in columns" :key="indexc">
1375
- <b-card-text v-if="column.type != 'actions'"
1376
- >{{ column.label }}:
1377
- <slot
1378
- :name="'cell-' + column.prop"
1379
- v-bind:item="item"
1380
- v-bind:index="index"
1381
- v-bind:itemindex="index"
1382
- v-bind:columnindex="indexc"
1383
- >
1193
+ <b-card-text v-if="column.type != 'actions'">{{ column.label }}:
1194
+ <slot :name="'cell-' + column.prop" v-bind:item="item" v-bind:index="index" v-bind:itemindex="index"
1195
+ v-bind:columnindex="indexc">
1384
1196
  <span v-if="column.type == 'boolean'">
1385
- <b-badge
1386
- variant="success"
1387
- v-if="
1388
- itemValue(column, item) == 'true' ||
1389
- itemValue(column, item) == 1 ||
1390
- itemValue(column, item) == '1'
1391
- "
1392
- ><b-icon-check-circle></b-icon-check-circle
1393
- ></b-badge>
1394
- <b-badge
1395
- variant="danger"
1396
- v-if="
1397
- !itemValue(column, item) ||
1398
- itemValue(column, item) == '0' ||
1399
- itemValue(column, item) == 'false'
1400
- "
1401
- ><b-icon-x-circle></b-icon-x-circle
1402
- ></b-badge>
1197
+ <b-badge variant="success" v-if="
1198
+ itemValue(column, item) == 'true' ||
1199
+ itemValue(column, item) == 1 ||
1200
+ itemValue(column, item) == '1'
1201
+ "><b-icon-check-circle></b-icon-check-circle></b-badge>
1202
+ <b-badge variant="danger" v-if="
1203
+ !itemValue(column, item) ||
1204
+ itemValue(column, item) == '0' ||
1205
+ itemValue(column, item) == 'false'
1206
+ "><b-icon-x-circle></b-icon-x-circle></b-badge>
1403
1207
  </span>
1404
1208
 
1405
1209
  <span v-else-if="column.type == 'date'">
@@ -1428,30 +1232,15 @@ export default /*#__PURE__*/ {
1428
1232
 
1429
1233
  <template v-slot:footer>
1430
1234
  <b-button-group>
1431
- <slot
1432
- name="rowAction"
1433
- v-bind:item="item"
1434
- v-bind:index="index"
1435
- v-bind:showItem="showItem"
1436
- v-bind:updateItem="updateItem"
1437
- v-bind:removeItem="removeItem"
1438
- >
1439
- <b-button
1440
- variant="primary"
1441
- @click="showItem(item.id, index)"
1442
- >
1235
+ <slot name="rowAction" v-bind:item="item" v-bind:index="index" v-bind:showItem="showItem"
1236
+ v-bind:updateItem="updateItem" v-bind:removeItem="removeItem">
1237
+ <b-button variant="primary" @click="showItem(item.id, index)">
1443
1238
  <b-icon-eye></b-icon-eye>
1444
1239
  </b-button>
1445
- <b-button
1446
- variant="secondary"
1447
- @click="updateItem(item.id, index)"
1448
- >
1240
+ <b-button variant="secondary" @click="updateItem(item.id, index)">
1449
1241
  <b-icon-pencil></b-icon-pencil>
1450
1242
  </b-button>
1451
- <b-button
1452
- variant="danger"
1453
- @click="removeItem(item.id, index)"
1454
- >
1243
+ <b-button variant="danger" @click="removeItem(item.id, index)">
1455
1244
  <b-icon-trash></b-icon-trash>
1456
1245
  </b-button>
1457
1246
  </slot>
@@ -1468,43 +1257,23 @@ export default /*#__PURE__*/ {
1468
1257
  {{ messageEmptyResults }}
1469
1258
  </p>
1470
1259
 
1471
- <div
1472
- :class="listItemClass"
1473
- v-for="(item, index) in items"
1474
- v-bind:key="index"
1475
- >
1260
+ <div :class="listItemClass" v-for="(item, index) in items" v-bind:key="index">
1476
1261
  <slot name="card" v-bind:item="item"> </slot>
1477
1262
  </div>
1478
1263
  </div>
1479
1264
  </div>
1480
1265
  </b-overlay>
1481
1266
  <div class="crud-paginator">
1482
- <b-pagination
1483
- v-if="showPaginator"
1484
- v-model="pagination.current_page"
1485
- :total-rows="pagination.total"
1486
- :per-page="pagination.per_page"
1487
- @change="onPaginationChange($event)"
1488
- ></b-pagination>
1267
+ <b-pagination v-if="showPaginator" v-model="pagination.current_page" :total-rows="pagination.total"
1268
+ :per-page="pagination.per_page" @change="onPaginationChange($event)"></b-pagination>
1489
1269
  </div>
1490
- <b-modal
1491
- :id="'modal-form-item-' + modelName"
1492
- hide-footer
1493
- size="xl"
1494
- :title="title"
1495
- no-close-on-backdrop
1496
- >
1270
+ <b-modal :id="'modal-form-item-' + modelName" hide-footer size="xl" :title="title" no-close-on-backdrop>
1497
1271
  <b-overlay :show="loading" rounded="sm">
1498
1272
  <template v-if="validate">
1499
1273
  <form @submit="saveItem">
1500
1274
  <slot name="form" v-bind:item="item">
1501
1275
  <b-form-group label="Nombre:" description="Nombre ">
1502
- <b-form-input
1503
- v-model="item.title"
1504
- type="text"
1505
- required
1506
- placeholder="Nombre"
1507
- ></b-form-input>
1276
+ <b-form-input v-model="item.title" type="text" required placeholder="Nombre"></b-form-input>
1508
1277
  </b-form-group>
1509
1278
  </slot>
1510
1279
  <b-button block type="submit" variant="success" :disabled="loading">
@@ -1515,33 +1284,16 @@ export default /*#__PURE__*/ {
1515
1284
  <template v-if="!validate">
1516
1285
  <slot name="form" v-bind:item="item">
1517
1286
  <b-form-group label="Nombre:" description="Nombre ">
1518
- <b-form-input
1519
- v-model="item.title"
1520
- type="text"
1521
- required
1522
- placeholder="Nombre"
1523
- ></b-form-input>
1287
+ <b-form-input v-model="item.title" type="text" required placeholder="Nombre"></b-form-input>
1524
1288
  </b-form-group>
1525
1289
  </slot>
1526
- <b-button
1527
- block
1528
- type="submit"
1529
- variant="success"
1530
- :disabled="loading"
1531
- @click="saveItem()"
1532
- >
1290
+ <b-button block type="submit" variant="success" :disabled="loading" @click="saveItem()">
1533
1291
  <b-spinner small v-if="loading"></b-spinner>{{ messageSave }}
1534
1292
  </b-button>
1535
1293
  </template>
1536
1294
  </b-overlay>
1537
1295
  </b-modal>
1538
- <b-modal
1539
- :id="'modal-show-item-' + modelName"
1540
- hide-footer
1541
- size="xl"
1542
- :title="title"
1543
- no-close-on-backdrop
1544
- >
1296
+ <b-modal :id="'modal-show-item-' + modelName" hide-footer size="xl" :title="title" no-close-on-backdrop>
1545
1297
  <slot name="show" v-bind:item="item">
1546
1298
  <p class="my-4">Show</p>
1547
1299
  </slot>
@@ -1555,10 +1307,12 @@ tr td:first-child {
1555
1307
  width: 1%;
1556
1308
  white-space: nowrap;
1557
1309
  }
1310
+
1558
1311
  .crud-pagination {
1559
1312
  display: flex;
1560
1313
  justify-content: center;
1561
1314
  }
1315
+
1562
1316
  .crud-header {
1563
1317
  display: flex;
1564
1318
  justify-content: space-between;
@@ -1583,6 +1337,7 @@ tr td:first-child {
1583
1337
  }
1584
1338
  }
1585
1339
  }
1340
+
1586
1341
  .table-options {
1587
1342
  margin-bottom: 1rem;
1588
1343
  display: flex;
@@ -1590,6 +1345,7 @@ tr td:first-child {
1590
1345
  justify-content: flex-end;
1591
1346
  }
1592
1347
  }
1348
+
1593
1349
  .custom-control {
1594
1350
  position: relative;
1595
1351
  top: -15px;
@@ -1602,9 +1358,12 @@ tr td:first-child {
1602
1358
  tbody {
1603
1359
  td {
1604
1360
  overflow: scroll;
1605
- -ms-overflow-style: none; /* IE and Edge */
1606
- scrollbar-width: none; /* Firefox */
1361
+ -ms-overflow-style: none;
1362
+ /* IE and Edge */
1363
+ scrollbar-width: none;
1364
+ /* Firefox */
1607
1365
  }
1366
+
1608
1367
  td::-webkit-scrollbar {
1609
1368
  display: none;
1610
1369
  }