Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions assets/js/app/editor/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import Vue from 'vue';
/**
* VueX Store
*/
import store from './store';
/**
* Components
*/
Expand Down Expand Up @@ -52,7 +48,6 @@ const editorSelector = '#' + id;

if (document.getElementById(id)) {
new Vue({
store,
el: editorSelector,
name: 'BoltEditor',
});
Expand Down
11 changes: 0 additions & 11 deletions assets/js/app/editor/store/index.js

This file was deleted.

7 changes: 0 additions & 7 deletions assets/js/app/editor/store/modules/general/_actions.js

This file was deleted.

5 changes: 0 additions & 5 deletions assets/js/app/editor/store/modules/general/_getters.js

This file was deleted.

7 changes: 0 additions & 7 deletions assets/js/app/editor/store/modules/general/_mutations.js

This file was deleted.

5 changes: 0 additions & 5 deletions assets/js/app/editor/store/modules/general/_state.js

This file was deleted.

12 changes: 0 additions & 12 deletions assets/js/app/editor/store/modules/general/index.js

This file was deleted.

23 changes: 9 additions & 14 deletions assets/js/app/listing/Components/Filter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
</template>

<script>
import { mapState } from 'pinia';
import type from '../mixins/type';
import { useGeneralStore, useSelectingStore } from '../store';

export default {
name: 'ListingFilter',
Expand All @@ -69,34 +71,27 @@ export default {
labels: Object,
},
computed: {
size() {
return this.$store.getters['general/getRowSize'];
},
sorting() {
return this.$store.getters['general/getSorting'];
},
selectAll() {
return this.$store.getters['selecting/selectAll'];
},
...mapState(useGeneralStore, { size: 'rowSize', sorting: 'sorting' }),
...mapState(useSelectingStore, ['selectAll']),
},
watch: {
sorting() {
if (this.sorting) this.$store.dispatch('selecting/selectAll', false);
if (this.sorting) useSelectingStore(this.$pinia).selectAll = false;
},
},
created() {
const size = localStorage.getItem('listing-row-size');
if (size !== null) this.$store.dispatch('general/setRowSize', size);
if (size !== null) useGeneralStore(this.$pinia).rowSize = size;
},
methods: {
enableSorting(arg) {
this.$store.dispatch('general/setSorting', arg);
useGeneralStore(this.$pinia).sorting = arg;
},
enableSelectAll(arg) {
this.$store.dispatch('selecting/selectAll', arg);
useSelectingStore(this.$pinia).selectAll = arg;
},
changeSize(size) {
this.$store.dispatch('general/setRowSize', size);
useGeneralStore(this.$pinia).rowSize = size;
localStorage.setItem('listing-row-size', size);
},
},
Expand Down
6 changes: 4 additions & 2 deletions assets/js/app/listing/Components/Records.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
</template>

<script>
import { useGeneralStore, useListingStore } from '../store';

export default {
name: 'ListingRecords',
props: {
Expand All @@ -11,8 +13,8 @@ export default {
labels: Object,
},
created() {
this.$store.dispatch('general/setType', this.type);
this.$store.dispatch('listing/setRecords', this.data);
useGeneralStore(this.$pinia).type = this.type;
useListingStore(this.$pinia).records = this.data;
},
};
</script>
18 changes: 9 additions & 9 deletions assets/js/app/listing/Components/SelectBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
</template>

<script>
import { mapState } from 'pinia';
import Multiselect from 'vue-multiselect';
import { useListingStore, useSelectingStore } from '../store';

export default {
name: 'ListingSelectedBox',
Expand Down Expand Up @@ -98,15 +100,13 @@ export default {

return '';
},
selectedCount() {
return this.$store.getters['selecting/selectedCount'];
},
selected() {
return this.$store.getters['selecting/selected'];
},
order() {
return this.$store.getters['listing/getOrder'];
},
...mapState(useSelectingStore, ['selectedCount', 'selected']),
// Dead code: nothing reads or submits `order`. It belongs to the
// unfinished drag-and-drop sorting of records, like the commented-out
// toggle in Filter.vue and the unused _Sorting.vue handle.
...mapState(useListingStore, {
order: store => store.records.map(record => record.id),
}),
},
};
</script>
15 changes: 7 additions & 8 deletions assets/js/app/listing/Components/Table/Row/_Checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
</template>

<script>
import { mapState } from 'pinia';
import { useGeneralStore, useSelectingStore } from '../../../store';

export default {
name: 'Checkbox',
props: {
Expand All @@ -19,21 +22,17 @@ export default {
};
},
computed: {
selectAll() {
return this.$store.getters['selecting/selectAll'];
},
sorting() {
return this.$store.getters['general/getSorting'];
},
...mapState(useSelectingStore, ['selectAll']),
...mapState(useGeneralStore, ['sorting']),
},
watch: {
selectAll() {
this.selected = this.selectAll;
},
selected() {
this.selected
? this.$store.dispatch('selecting/select', this.id)
: this.$store.dispatch('selecting/deSelect', this.id);
? useSelectingStore(this.$pinia).select(this.id)
: useSelectingStore(this.$pinia).deSelect(this.id);
},
sorting() {
if (this.sorting) this.selected = false;
Expand Down
7 changes: 4 additions & 3 deletions assets/js/app/listing/Components/Table/Row/_Sorting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
</template>

<script>
import { mapState } from 'pinia';
import { useGeneralStore } from '../../../store';

export default {
name: 'Sorting',
computed: {
sorting() {
return this.$store.getters['general/getSorting'];
},
...mapState(useGeneralStore, ['sorting']),
},
};
</script>
9 changes: 3 additions & 6 deletions assets/js/app/listing/Components/Table/Row/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
</template>

<script>
import { mapState } from 'pinia';
import type from '../../../mixins/type';
import { useGeneralStore } from '../../../store';
import { raw, trim } from '../../../../../filters/string';
import Checkbox from './_Checkbox';
import Meta from './_Meta';
Expand Down Expand Up @@ -74,12 +76,7 @@ export default {
// if slug has different locales, return the 0st one
return this.record.fieldValues.slug[Object.keys(this.record.fieldValues.slug)[0]];
},
size() {
return this.$store.getters['general/getRowSize'];
},
sorting() {
return this.$store.getters['general/getSorting'];
},
...mapState(useGeneralStore, { size: 'rowSize', sorting: 'sorting' }),
},
methods: {
raw,
Expand Down
11 changes: 3 additions & 8 deletions assets/js/app/listing/Components/Table/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
</template>

<script>
import { mapWritableState } from 'pinia';
import draggable from 'vuedraggable';
import Row from './Row';
import { useListingStore } from '../../store';

export default {
name: 'ListingTable',
Expand All @@ -22,14 +24,7 @@ export default {
labels: Object,
},
computed: {
records: {
get() {
return this.$store.getters['listing/getRecords'];
},
set(val) {
this.$store.dispatch('listing/setRecords', val);
},
},
...mapWritableState(useListingStore, ['records']),
},
};
</script>
8 changes: 5 additions & 3 deletions assets/js/app/listing/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Vue from 'vue';
/**
* VueX Store
* Pinia
*/
import store from './store';
import { createPinia, PiniaVuePlugin } from 'pinia';
/**
* Components
*/
Expand All @@ -11,14 +11,16 @@ import Filter from './Components/Filter';
import Table from './Components/Table';
import SelectBox from './Components/SelectBox';

Vue.use(PiniaVuePlugin);

/**
* Register Components
*/
const id = 'listing';

if (document.getElementById(id)) {
new Vue({
store,
pinia: createPinia(),
el: '#' + id,
name: 'BoltListing',
components: {
Expand Down
7 changes: 4 additions & 3 deletions assets/js/app/listing/mixins/type.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { mapState } from 'pinia';
import { useGeneralStore } from '../store';

export default {
computed: {
type() {
return this.$store.getters['general/getType'];
},
...mapState(useGeneralStore, ['type']),
},
};
18 changes: 0 additions & 18 deletions assets/js/app/listing/store/index.js

This file was deleted.

52 changes: 52 additions & 0 deletions assets/js/app/listing/store/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { defineStore } from 'pinia';
import type { ListingRecord } from '../types';

interface GeneralState {
type: string | null;
rowSize: string;
sorting: boolean;
}

export const useGeneralStore = defineStore('listing-general', {
state: (): GeneralState => ({
type: null,
rowSize: 'normal',
sorting: false,
}),
});

interface ListingState {
records: ListingRecord[];
}

export const useListingStore = defineStore('listing', {
state: (): ListingState => ({
records: [],
}),
});

interface SelectingState {
selectAll: boolean;
selected: number[];
}

export const useSelectingStore = defineStore('selecting', {
state: (): SelectingState => ({
selectAll: false,
selected: [],
}),
getters: {
selectedCount: state => state.selected.length,
},
actions: {
select(id: number) {
if (!this.selected.includes(id)) {
this.selected.push(id);
}
},
deSelect(id: number) {
const index = this.selected.indexOf(id);
if (index > -1) this.selected.splice(index, 1);
},
},
});
Loading
Loading