vue-laravel-crud 1.3.19 → 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,7 +460,17 @@ export default /*#__PURE__*/ {
450
460
  this.selectedItems.push(this.item);
451
461
  }
452
462
  },
453
-
463
+ externalUpdate(itemsUpdate, addIfNotExist = true, key = 'id') {
464
+ itemsUpdate.forEach(itemUpdate => {
465
+ let itemInList = this.items.find(item => item[key] === itemUpdate[key]);
466
+ if (itemInList) Object.assign(itemInList, itemUpdate);
467
+ else {
468
+ if (addIfNotExist) {
469
+ this.items.push(itemUpdate);
470
+ }
471
+ }
472
+ });
473
+ },
454
474
  getSelectedItems() {
455
475
  return this.selectedItems;
456
476
  },
@@ -487,7 +507,7 @@ export default /*#__PURE__*/ {
487
507
 
488
508
  refresh() {
489
509
  this.$emit("refresh", {});
490
- if(!this.ajax){
510
+ if (!this.ajax) {
491
511
  return;
492
512
  }
493
513
  this.fetchItems(this.pagination.current_page);
@@ -503,11 +523,27 @@ export default /*#__PURE__*/ {
503
523
  this.refresh();
504
524
  }, 1);
505
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
+ },
506
539
  fetchItems(page = 1) {
507
- if(!this.ajax){
540
+ if (!this.ajax) {
508
541
  return;
509
542
  }
510
543
  this.$emit("beforeFetch", {});
544
+ if (this.useMc) {
545
+ return this.fetchItemsMc(page);
546
+ }
511
547
  this.loading = true;
512
548
  axios
513
549
  .get(this.apiUrl + "/" + this.modelName, {
@@ -553,7 +589,7 @@ export default /*#__PURE__*/ {
553
589
  }
554
590
 
555
591
  this.loading = false;
556
- this.$emit("afterFetch", {});
592
+ this.$emit("afterFetch", {});
557
593
  })
558
594
  .catch((error) => {
559
595
  //console.debug(error);
@@ -577,12 +613,12 @@ export default /*#__PURE__*/ {
577
613
  this.loading = true;
578
614
  axios
579
615
  .delete(this.apiUrl + "/" + this.modelName + "/" + id)
580
- .then( (response) => {
616
+ .then((response) => {
581
617
  this.items.splice(index, 1);
582
618
  this.toastSuccess("Elemento eliminado.");
583
619
  this.loading = false;
584
620
  })
585
- .catch( (error) => {
621
+ .catch((error) => {
586
622
  this.toastError(error);
587
623
  this.loading = false;
588
624
  });
@@ -606,13 +642,13 @@ export default /*#__PURE__*/ {
606
642
  .post(this.apiUrl + "/" + this.modelName + "/sort", {
607
643
  order: order,
608
644
  })
609
- .then( (response) => {
645
+ .then((response) => {
610
646
  let data = response.data;
611
647
  this.toastSuccess("Orden Actualizado");
612
648
  if (this.refreshAfterSave) this.refresh();
613
649
  this.loading = false;
614
650
  })
615
- .catch( (error) => {
651
+ .catch((error) => {
616
652
  //console.debug(error);
617
653
  this.toastError(error);
618
654
  this.loading = false;
@@ -678,7 +714,7 @@ export default /*#__PURE__*/ {
678
714
  this.item
679
715
  )
680
716
  .then((response) => {
681
- if(this.hideModalAfterSave){
717
+ if (this.hideModalAfterSave) {
682
718
  this.$bvModal.hide("modal-form-item-" + this.modelName);
683
719
  }
684
720
 
@@ -715,9 +751,9 @@ export default /*#__PURE__*/ {
715
751
 
716
752
  axios
717
753
  .post(this.apiUrl + "/" + this.modelName, formData)
718
- .then( (response) => {
754
+ .then((response) => {
719
755
  this.loading = false;
720
- if(this.hideModalAfterSave){
756
+ if (this.hideModalAfterSave) {
721
757
  this.$bvModal.hide("modal-form-item-" + this.modelName);
722
758
  }
723
759
  if (response.data.success) {
@@ -734,16 +770,16 @@ export default /*#__PURE__*/ {
734
770
  if (this.refreshAfterSave) this.refresh();
735
771
  this.toastSuccess("Elemento Creado");
736
772
  })
737
- .catch( (error) => {
773
+ .catch((error) => {
738
774
  this.toastError(error);
739
775
  this.loading = false;
740
776
  });
741
777
  } else {
742
778
  axios
743
779
  .post(this.apiUrl + "/" + this.modelName, this.item)
744
- .then( (response) => {
780
+ .then((response) => {
745
781
  this.loading = false;
746
- if(this.hideModalAfterSave){
782
+ if (this.hideModalAfterSave) {
747
783
  this.$bvModal.hide("modal-form-item-" + this.modelName);
748
784
  }
749
785
  if (response.data.success) {
@@ -760,7 +796,7 @@ export default /*#__PURE__*/ {
760
796
  if (this.refreshAfterSave) this.refresh();
761
797
  this.toastSuccess("Elemento Creado");
762
798
  })
763
- .catch( (error) => {
799
+ .catch((error) => {
764
800
  this.toastError(error);
765
801
  this.loading = false;
766
802
  });
@@ -842,32 +878,18 @@ export default /*#__PURE__*/ {
842
878
  <h4 class="crud-title" v-if="showTitle">{{ title }}</h4>
843
879
 
844
880
  <b-sidebar v-model="filterSidebarOpen" title="Filtrar" right shadow>
845
- <slot
846
- name="sidebarFilters"
847
- v-bind:createItem="createItem"
848
- v-bind:toggleDisplayMode="toggleDisplayMode"
849
- v-bind:loading="loading"
850
- v-bind:isColumnHasFilter="isColumnHasFilter"
851
- v-bind:setFilter="setFilter"
852
- >
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">
853
883
  <div class="px-3 py-2">
854
884
  <div v-for="(column, indexc) in columns" :key="indexc">
855
885
  <div v-if="isColumnHasFilter(column)">
856
- <slot
857
- :name="'sidebar-filter-' + column.prop"
858
- v-bind:column="column"
859
- v-bind:filter="filter"
860
- v-bind:internalFilterByProp="internalFilterByProp"
861
- v-if="internalFilterByProp(column.prop)"
862
- >
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)">
863
888
  <div class="form-group" v-if="column.type == 'boolean'">
864
889
  <label>{{ column.label }}</label>
865
890
 
866
- <select
867
- class="form-control"
868
- v-model="internalFilterByProp(column.prop).value"
869
- @change="onChangeFilter($event)"
870
- >
891
+ <select class="form-control" v-model="internalFilterByProp(column.prop).value"
892
+ @change="onChangeFilter($event)">
871
893
  <option value=""></option>
872
894
  <option value="1">Sí</option>
873
895
  <option value="0">No</option>
@@ -876,26 +898,14 @@ export default /*#__PURE__*/ {
876
898
  <div class="form-group" v-else-if="column.type == 'date'">
877
899
  <div class="row">
878
900
  <div class="col-6">
879
- <b-form-datepicker
880
- v-model="
881
- internalFilterByProp(column.prop + '_from').value
882
- "
883
- today-button
884
- reset-button
885
- close-button
886
- locale="es"
887
- ></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>
888
904
  </div>
889
905
  <div class="col-6">
890
- <b-form-datepicker
891
- v-model="
892
- internalFilterByProp(column.prop + '_to').value
893
- "
894
- today-button
895
- reset-button
896
- close-button
897
- locale="es"
898
- ></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>
899
909
  </div>
900
910
  </div>
901
911
  </div>
@@ -904,21 +914,14 @@ export default /*#__PURE__*/ {
904
914
  <label>{{ column.label }}</label>
905
915
  <div class="d-none">{{ column.options }}</div>
906
916
 
907
- <select
908
- class="form-control"
909
- v-model="internalFilterByProp(column.prop).value"
910
- @change="onChangeFilter($event)"
911
- >
917
+ <select class="form-control" v-model="internalFilterByProp(column.prop).value"
918
+ @change="onChangeFilter($event)">
912
919
  <option value=""></option>
913
- <option
914
- :value="option.id"
915
- v-for="option in column.options"
916
- :key="option.id"
917
- >
920
+ <option :value="option.id" v-for="option in column.options" :key="option.id">
918
921
  {{
919
922
  option.text
920
- ? option.text
921
- : option.label
923
+ ? option.text
924
+ : option.label
922
925
  ? option.label
923
926
  : ""
924
927
  }}
@@ -930,22 +933,15 @@ export default /*#__PURE__*/ {
930
933
  <label>{{ column.label }}</label>
931
934
  <div class="d-none">{{ column.options }}</div>
932
935
 
933
- <select
934
- class="form-control"
935
- v-model="internalFilterByProp(column.prop).value"
936
- @change="onChangeFilter($event)"
937
- >
936
+ <select class="form-control" v-model="internalFilterByProp(column.prop).value"
937
+ @change="onChangeFilter($event)">
938
938
  <option value=""></option>
939
939
  <template v-if="column.options">
940
- <option
941
- :value="option.id"
942
- v-for="option in column.options"
943
- :key="option.id"
944
- >
940
+ <option :value="option.id" v-for="option in column.options" :key="option.id">
945
941
  {{
946
942
  option.text
947
- ? option.text
948
- : option.label
943
+ ? option.text
944
+ : option.label
949
945
  ? option.label
950
946
  : ""
951
947
  }}
@@ -957,11 +953,8 @@ export default /*#__PURE__*/ {
957
953
  <div class="form-group" v-else>
958
954
  <label>{{ column.label }}</label>
959
955
 
960
- <input
961
- class="form-control"
962
- v-model.lazy="internalFilterByProp(column.prop).value"
963
- @change="onChangeFilter($event)"
964
- />
956
+ <input class="form-control" v-model.lazy="internalFilterByProp(column.prop).value"
957
+ @change="onChangeFilter($event)" />
965
958
  </div>
966
959
  </slot>
967
960
  </div>
@@ -981,63 +974,30 @@ export default /*#__PURE__*/ {
981
974
 
982
975
  <div class="table-options">
983
976
  <b-button-group class="mr-1">
984
- <slot
985
- name="tableActions"
986
- v-bind:createItem="createItem"
987
- v-bind:toggleDisplayMode="toggleDisplayMode"
988
- v-bind:loading="loading"
989
- >
977
+ <slot name="tableActions" v-bind:createItem="createItem" v-bind:toggleDisplayMode="toggleDisplayMode"
978
+ v-bind:loading="loading">
990
979
  <slot name="tableActionsPrepend" v-bind:loading="loading"> </slot>
991
- <b-button
992
- variant="success"
993
- v-if="showCreateBtn"
994
- @click="createItem()"
995
- :disabled="loading"
996
- >
980
+ <b-button variant="success" v-if="showCreateBtn" @click="createItem()" :disabled="loading">
997
981
  <b-icon-plus></b-icon-plus>{{ messageNew }}
998
982
  </b-button>
999
983
 
1000
- <b-button v-if="enableFilters" @click="toggleFilters()"
1001
- >Filtros</b-button
1002
- >
1003
-
1004
- <b-button @click="refresh()"
1005
- ><b-icon-arrow-clockwise></b-icon-arrow-clockwise
1006
- ></b-button>
1007
-
1008
- <b-button
1009
- variant="info"
1010
- @click="toggleDisplayMode()"
1011
- :disabled="loading"
1012
- v-if="displayModeToggler"
1013
- >
1014
- <b-icon-card-list
1015
- v-if="displayMode == displayModes.MODE_TABLE"
1016
- ></b-icon-card-list>
1017
- <b-icon-table
1018
- v-if="displayMode == displayModes.MODE_CARDS"
1019
- ></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>
1020
991
  </b-button>
1021
992
 
1022
993
  <div class="crud-search m-0" v-if="showSearch">
1023
994
  <b-input-group>
1024
995
  <b-input-group-prepend>
1025
- <b-button
1026
- variant="info"
1027
- @click="displaySearch = !displaySearch"
1028
- :class="{ open: displaySearch }"
1029
- ><b-icon-search></b-icon-search
1030
- ></b-button>
996
+ <b-button variant="info" @click="displaySearch = !displaySearch"
997
+ :class="{ open: displaySearch }"><b-icon-search></b-icon-search></b-button>
1031
998
  </b-input-group-prepend>
1032
- <b-form-input
1033
- v-if="displaySearch"
1034
- v-model="search"
1035
- class="pl-2"
1036
- type="search"
1037
- required
1038
- :placeholder="searchPlaceholder"
1039
- debounce="500"
1040
- ></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>
1041
1001
  </b-input-group>
1042
1002
 
1043
1003
  <slot name="tableActionsAppend" v-bind:loading="loading"> </slot>
@@ -1047,38 +1007,22 @@ export default /*#__PURE__*/ {
1047
1007
  </div>
1048
1008
  </div>
1049
1009
  <b-overlay :show="loading" rounded="sm">
1050
- <div
1051
- :class="['table-responsive', tableContainerClass]"
1052
- v-if="displayMode == displayModes.MODE_TABLE"
1053
- >
1010
+ <div :class="['table-responsive', tableContainerClass]" v-if="displayMode == displayModes.MODE_TABLE">
1054
1011
  <table :class="['table table-hover table-striped w-100', tableClass]">
1055
1012
  <thead class="thead-light">
1056
1013
  <tr>
1057
1014
  <slot name="rowHead">
1058
- <th
1059
- v-for="(column, indexc) in columns"
1060
- :key="indexc"
1061
- :style="{ width: column.width ? column.width : 'inherit' }"
1062
- scope="col"
1063
- >
1064
- <slot
1065
- :name="'filter-' + column.prop"
1066
- v-bind:column="column"
1067
- v-bind:filter="filter"
1068
- v-bind:internalFilterByProp="internalFilterByProp"
1069
- 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="
1070
1019
  enableFilters &&
1071
1020
  filtersVisible &&
1072
1021
  isColumnHasFilter(column) &&
1073
1022
  internalFilterByProp(column.prop)
1074
- "
1075
- >
1076
- <select
1077
- v-if="column.type == 'boolean'"
1078
- class="form-control"
1079
- v-model="internalFilterByProp(column.prop).value"
1080
- @change="onChangeFilter($event)"
1081
- >
1023
+ ">
1024
+ <select v-if="column.type == 'boolean'" class="form-control"
1025
+ v-model="internalFilterByProp(column.prop).value" @change="onChangeFilter($event)">
1082
1026
  <option value="">{{ column.label }}</option>
1083
1027
  <option value="1">Sí</option>
1084
1028
  <option value="0">No</option>
@@ -1086,133 +1030,72 @@ export default /*#__PURE__*/ {
1086
1030
 
1087
1031
  <div class="row" v-else-if="column.type == 'date'">
1088
1032
  <div class="col-6">
1089
- <b-form-datepicker
1090
- v-model="
1091
- internalFilterByProp(column.prop + '_from').value
1092
- "
1093
- today-button
1094
- reset-button
1095
- close-button
1096
- locale="es"
1097
- ></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>
1098
1036
  </div>
1099
1037
  <div class="col-6">
1100
- <b-form-datepicker
1101
- v-model="
1102
- internalFilterByProp(column.prop + '_to').value
1103
- "
1104
- today-button
1105
- reset-button
1106
- close-button
1107
- locale="es"
1108
- ></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>
1109
1041
  </div>
1110
1042
  </div>
1111
1043
 
1112
- <select
1113
- v-else-if="column.type == 'state'"
1114
- class="form-control"
1115
- v-model="internalFilterByProp(column.prop).value"
1116
- @change="onChangeFilter($event)"
1117
- >
1044
+ <select v-else-if="column.type == 'state'" class="form-control"
1045
+ v-model="internalFilterByProp(column.prop).value" @change="onChangeFilter($event)">
1118
1046
  <option value="">{{ column.label }}</option>
1119
- <option
1120
- :value="option.id"
1121
- v-for="(option, indexo) in column.options"
1122
- :key="indexo"
1123
- >
1047
+ <option :value="option.id" v-for="(option, indexo) in column.options" :key="indexo">
1124
1048
  {{
1125
1049
  option.text
1126
- ? option.text
1127
- : option.label
1050
+ ? option.text
1051
+ : option.label
1128
1052
  ? option.label
1129
1053
  : ""
1130
1054
  }}
1131
1055
  </option>
1132
1056
  </select>
1133
1057
 
1134
- <select
1135
- v-else-if="column.type == 'array'"
1136
- class="form-control"
1137
- v-model="internalFilterByProp(column.prop).value"
1138
- @change="onChangeFilter($event)"
1139
- >
1058
+ <select v-else-if="column.type == 'array'" class="form-control"
1059
+ v-model="internalFilterByProp(column.prop).value" @change="onChangeFilter($event)">
1140
1060
  <option value="">{{ column.label }}</option>
1141
- <option
1142
- :value="option.id"
1143
- v-for="(option, indexo) in column.options"
1144
- :key="indexo"
1145
- >
1061
+ <option :value="option.id" v-for="(option, indexo) in column.options" :key="indexo">
1146
1062
  {{
1147
1063
  option.text
1148
- ? option.text
1149
- : option.label
1064
+ ? option.text
1065
+ : option.label
1150
1066
  ? option.label
1151
1067
  : ""
1152
1068
  }}
1153
1069
  </option>
1154
1070
  </select>
1155
1071
 
1156
- <b-form-checkbox
1157
- v-else-if="column.type == 'checkbox'"
1158
- name="select-all"
1159
- @change="toggleAll()"
1160
- >
1072
+ <b-form-checkbox v-else-if="column.type == 'checkbox'" name="select-all" @change="toggleAll()">
1161
1073
  </b-form-checkbox>
1162
- <input
1163
- v-else
1164
- class="form-control"
1165
- v-model="internalFilterByProp(column.prop).value"
1166
- :placeholder="column.label"
1167
- @change="onChangeFilter($event)"
1168
- />
1074
+ <input v-else class="form-control" v-model="internalFilterByProp(column.prop).value"
1075
+ :placeholder="column.label" @change="onChangeFilter($event)" />
1169
1076
  </slot>
1170
1077
 
1171
1078
  <span v-else>{{ column.label }}</span>
1172
1079
 
1173
- <span
1174
- v-if="
1175
- sortable && internalFilterByProp(column.prop + '_sort')
1176
- "
1177
- class="sort-filter"
1178
- @click="toggleSortFilter(column)"
1179
- ><b-icon-sort
1180
- v-if="!internalFilterByProp(column.prop + '_sort').value"
1181
- ></b-icon-sort
1182
- ><b-icon-sort-up
1183
- 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="
1184
1084
  internalFilterByProp(column.prop + '_sort').value ==
1185
1085
  'ASC'
1186
- "
1187
- ></b-icon-sort-up
1188
- ><b-icon-sort-down
1189
- v-if="
1190
- internalFilterByProp(column.prop + '_sort').value ==
1191
- 'DESC'
1192
- "
1193
- ></b-icon-sort-down
1194
- ></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>
1195
1090
  </th>
1196
1091
  </slot>
1197
1092
  </tr>
1198
1093
  </thead>
1199
1094
 
1200
- <draggable
1201
- v-model="items"
1202
- group="people"
1203
- tag="tbody"
1204
- :draggable="orderable ? '.item' : '.none'"
1205
- @start="drag = true"
1206
- @end="drag = false"
1207
- @sort="onSort()"
1208
- >
1209
- <tr
1210
- v-for="(item, index) in items"
1211
- v-bind:key="index"
1212
- @mouseover="onRowHover(item, index)"
1213
- @click="onRowClick(item, index)"
1214
- class="item"
1215
- >
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">
1216
1099
  <template v-if="item.group">
1217
1100
  <th :colspan="columns.length">
1218
1101
  <span>{{ item.label }}</span>
@@ -1220,52 +1103,32 @@ export default /*#__PURE__*/ {
1220
1103
  </template>
1221
1104
  <template v-else>
1222
1105
  <slot name="row" v-bind:item="item">
1223
- <td
1224
- v-for="(column, indexc) in columns"
1225
- :key="indexc"
1226
- :scope="column.prop == 'id' ? 'row' : ''"
1227
- >
1228
- <slot
1229
- :name="'cell-' + column.prop"
1230
- v-bind:item="item"
1231
- v-bind:index="index"
1232
- v-bind:itemindex="index"
1233
- v-bind:columnindex="indexc"
1234
- >
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">
1235
1109
  <span v-if="column.type == 'boolean'">
1236
- <b-badge
1237
- variant="success"
1238
- v-if="
1239
- itemValue(column, item) == 'true' ||
1240
- itemValue(column, item) == 1 ||
1241
- itemValue(column, item) == '1'
1242
- "
1243
- ><b-icon-check-circle></b-icon-check-circle
1244
- ></b-badge>
1245
- <b-badge
1246
- variant="danger"
1247
- v-if="
1248
- !itemValue(column, item) ||
1249
- itemValue(column, item) == '0' ||
1250
- itemValue(column, item) == 'false'
1251
- "
1252
- ><b-icon-x-circle></b-icon-x-circle
1253
- ></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>
1254
1120
  </span>
1255
1121
  <span v-else-if="column.type == 'date'">
1256
1122
  {{
1257
1123
  itemValue(column, item) && column.format
1258
- ? moment(itemValue(column, item)).format(
1259
- column.format
1260
- )
1261
- : itemValue(column, item)
1124
+ ? moment(itemValue(column, item)).format(
1125
+ column.format
1126
+ )
1127
+ : itemValue(column, item)
1262
1128
  }}
1263
1129
  </span>
1264
1130
  <span v-else-if="column.type == 'checkbox'">
1265
- <b-form-checkbox
1266
- v-model="item.selected"
1267
- @change="onCheckSelect($event, item)"
1268
- >
1131
+ <b-form-checkbox v-model="item.selected" @change="onCheckSelect($event, item)">
1269
1132
  </b-form-checkbox>
1270
1133
  </span>
1271
1134
 
@@ -1290,30 +1153,15 @@ export default /*#__PURE__*/ {
1290
1153
  </slot>
1291
1154
 
1292
1155
  <b-button-group v-if="column.type == 'actions'">
1293
- <slot
1294
- name="rowAction"
1295
- v-bind:item="item"
1296
- v-bind:index="index"
1297
- v-bind:showItem="showItem"
1298
- v-bind:updateItem="updateItem"
1299
- v-bind:removeItem="removeItem"
1300
- >
1301
- <b-button
1302
- variant="primary"
1303
- @click="showItem(item.id, index)"
1304
- >
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)">
1305
1159
  <b-icon-eye></b-icon-eye>
1306
1160
  </b-button>
1307
- <b-button
1308
- variant="secondary"
1309
- @click="updateItem(item.id, index)"
1310
- >
1161
+ <b-button variant="secondary" @click="updateItem(item.id, index)">
1311
1162
  <b-icon-pencil></b-icon-pencil>
1312
1163
  </b-button>
1313
- <b-button
1314
- variant="danger"
1315
- @click="removeItem(item.id, index)"
1316
- >
1164
+ <b-button variant="danger" @click="removeItem(item.id, index)">
1317
1165
  <b-icon-trash></b-icon-trash>
1318
1166
  </b-button>
1319
1167
  </slot>
@@ -1334,62 +1182,28 @@ export default /*#__PURE__*/ {
1334
1182
  {{ messageEmptyResults }}
1335
1183
  </p>
1336
1184
 
1337
- <draggable
1338
- v-model="items"
1339
- group="people"
1340
- class="row"
1341
- :draggable="orderable ? '.item' : '.none'"
1342
- @start="drag = true"
1343
- @end="drag = false"
1344
- @sort="onSort()"
1345
- >
1346
- <b-col
1347
- v-for="(item, index) in items"
1348
- v-bind:key="index"
1349
- :cols="colXs"
1350
- :sm="colSm"
1351
- :md="colMd"
1352
- :lg="colLg"
1353
- :xl="colXl"
1354
- class="item"
1355
- >
1356
- <b-card
1357
- :title="item.title"
1358
- tag="article"
1359
- class="mb-2 card-crud"
1360
- :class="cardClass"
1361
- :hideFooter="cardHideFooter"
1362
- >
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">
1363
1191
  <slot name="card" v-bind:item="item">
1364
1192
  <div v-for="(column, indexc) in columns" :key="indexc">
1365
- <b-card-text v-if="column.type != 'actions'"
1366
- >{{ column.label }}:
1367
- <slot
1368
- :name="'cell-' + column.prop"
1369
- v-bind:item="item"
1370
- v-bind:index="index"
1371
- v-bind:itemindex="index"
1372
- v-bind:columnindex="indexc"
1373
- >
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">
1374
1196
  <span v-if="column.type == 'boolean'">
1375
- <b-badge
1376
- variant="success"
1377
- v-if="
1378
- itemValue(column, item) == 'true' ||
1379
- itemValue(column, item) == 1 ||
1380
- itemValue(column, item) == '1'
1381
- "
1382
- ><b-icon-check-circle></b-icon-check-circle
1383
- ></b-badge>
1384
- <b-badge
1385
- variant="danger"
1386
- v-if="
1387
- !itemValue(column, item) ||
1388
- itemValue(column, item) == '0' ||
1389
- itemValue(column, item) == 'false'
1390
- "
1391
- ><b-icon-x-circle></b-icon-x-circle
1392
- ></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>
1393
1207
  </span>
1394
1208
 
1395
1209
  <span v-else-if="column.type == 'date'">
@@ -1418,30 +1232,15 @@ export default /*#__PURE__*/ {
1418
1232
 
1419
1233
  <template v-slot:footer>
1420
1234
  <b-button-group>
1421
- <slot
1422
- name="rowAction"
1423
- v-bind:item="item"
1424
- v-bind:index="index"
1425
- v-bind:showItem="showItem"
1426
- v-bind:updateItem="updateItem"
1427
- v-bind:removeItem="removeItem"
1428
- >
1429
- <b-button
1430
- variant="primary"
1431
- @click="showItem(item.id, index)"
1432
- >
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)">
1433
1238
  <b-icon-eye></b-icon-eye>
1434
1239
  </b-button>
1435
- <b-button
1436
- variant="secondary"
1437
- @click="updateItem(item.id, index)"
1438
- >
1240
+ <b-button variant="secondary" @click="updateItem(item.id, index)">
1439
1241
  <b-icon-pencil></b-icon-pencil>
1440
1242
  </b-button>
1441
- <b-button
1442
- variant="danger"
1443
- @click="removeItem(item.id, index)"
1444
- >
1243
+ <b-button variant="danger" @click="removeItem(item.id, index)">
1445
1244
  <b-icon-trash></b-icon-trash>
1446
1245
  </b-button>
1447
1246
  </slot>
@@ -1458,43 +1257,23 @@ export default /*#__PURE__*/ {
1458
1257
  {{ messageEmptyResults }}
1459
1258
  </p>
1460
1259
 
1461
- <div
1462
- :class="listItemClass"
1463
- v-for="(item, index) in items"
1464
- v-bind:key="index"
1465
- >
1260
+ <div :class="listItemClass" v-for="(item, index) in items" v-bind:key="index">
1466
1261
  <slot name="card" v-bind:item="item"> </slot>
1467
1262
  </div>
1468
1263
  </div>
1469
1264
  </div>
1470
1265
  </b-overlay>
1471
1266
  <div class="crud-paginator">
1472
- <b-pagination
1473
- v-if="showPaginator"
1474
- v-model="pagination.current_page"
1475
- :total-rows="pagination.total"
1476
- :per-page="pagination.per_page"
1477
- @change="onPaginationChange($event)"
1478
- ></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>
1479
1269
  </div>
1480
- <b-modal
1481
- :id="'modal-form-item-' + modelName"
1482
- hide-footer
1483
- size="xl"
1484
- :title="title"
1485
- no-close-on-backdrop
1486
- >
1270
+ <b-modal :id="'modal-form-item-' + modelName" hide-footer size="xl" :title="title" no-close-on-backdrop>
1487
1271
  <b-overlay :show="loading" rounded="sm">
1488
1272
  <template v-if="validate">
1489
1273
  <form @submit="saveItem">
1490
1274
  <slot name="form" v-bind:item="item">
1491
1275
  <b-form-group label="Nombre:" description="Nombre ">
1492
- <b-form-input
1493
- v-model="item.title"
1494
- type="text"
1495
- required
1496
- placeholder="Nombre"
1497
- ></b-form-input>
1276
+ <b-form-input v-model="item.title" type="text" required placeholder="Nombre"></b-form-input>
1498
1277
  </b-form-group>
1499
1278
  </slot>
1500
1279
  <b-button block type="submit" variant="success" :disabled="loading">
@@ -1505,33 +1284,16 @@ export default /*#__PURE__*/ {
1505
1284
  <template v-if="!validate">
1506
1285
  <slot name="form" v-bind:item="item">
1507
1286
  <b-form-group label="Nombre:" description="Nombre ">
1508
- <b-form-input
1509
- v-model="item.title"
1510
- type="text"
1511
- required
1512
- placeholder="Nombre"
1513
- ></b-form-input>
1287
+ <b-form-input v-model="item.title" type="text" required placeholder="Nombre"></b-form-input>
1514
1288
  </b-form-group>
1515
1289
  </slot>
1516
- <b-button
1517
- block
1518
- type="submit"
1519
- variant="success"
1520
- :disabled="loading"
1521
- @click="saveItem()"
1522
- >
1290
+ <b-button block type="submit" variant="success" :disabled="loading" @click="saveItem()">
1523
1291
  <b-spinner small v-if="loading"></b-spinner>{{ messageSave }}
1524
1292
  </b-button>
1525
1293
  </template>
1526
1294
  </b-overlay>
1527
1295
  </b-modal>
1528
- <b-modal
1529
- :id="'modal-show-item-' + modelName"
1530
- hide-footer
1531
- size="xl"
1532
- :title="title"
1533
- no-close-on-backdrop
1534
- >
1296
+ <b-modal :id="'modal-show-item-' + modelName" hide-footer size="xl" :title="title" no-close-on-backdrop>
1535
1297
  <slot name="show" v-bind:item="item">
1536
1298
  <p class="my-4">Show</p>
1537
1299
  </slot>
@@ -1545,10 +1307,12 @@ tr td:first-child {
1545
1307
  width: 1%;
1546
1308
  white-space: nowrap;
1547
1309
  }
1310
+
1548
1311
  .crud-pagination {
1549
1312
  display: flex;
1550
1313
  justify-content: center;
1551
1314
  }
1315
+
1552
1316
  .crud-header {
1553
1317
  display: flex;
1554
1318
  justify-content: space-between;
@@ -1573,6 +1337,7 @@ tr td:first-child {
1573
1337
  }
1574
1338
  }
1575
1339
  }
1340
+
1576
1341
  .table-options {
1577
1342
  margin-bottom: 1rem;
1578
1343
  display: flex;
@@ -1580,6 +1345,7 @@ tr td:first-child {
1580
1345
  justify-content: flex-end;
1581
1346
  }
1582
1347
  }
1348
+
1583
1349
  .custom-control {
1584
1350
  position: relative;
1585
1351
  top: -15px;
@@ -1592,9 +1358,12 @@ tr td:first-child {
1592
1358
  tbody {
1593
1359
  td {
1594
1360
  overflow: scroll;
1595
- -ms-overflow-style: none; /* IE and Edge */
1596
- scrollbar-width: none; /* Firefox */
1361
+ -ms-overflow-style: none;
1362
+ /* IE and Edge */
1363
+ scrollbar-width: none;
1364
+ /* Firefox */
1597
1365
  }
1366
+
1598
1367
  td::-webkit-scrollbar {
1599
1368
  display: none;
1600
1369
  }