Skip to content

Commit ceb7d93

Browse files
[2.x] UI Updates (#116)
* Require alpha 15 * Update npm dependencies, vite config and make a build work * Wrap component registration in `Statamic.booting()` callback * Move icon into resources/svg * Imports listing * Create import form * edit page * wip * wip * New icon * Fix styling * Only show blueprint dropdown when type & collection/taxonomy have been selected * Add icons to listing actions * Setup TailwindCSS build To ensure any classes we're using in the importer addon don't disapper with updates to core. * Re-work destination fields - The group fieldtype no longer uses the config layout, which we want in our context. - We also don't need its additional padding, borders, full screen mode. So... I've created a new import_destination fieldtype which extends the Group fieldtype, just with a custom Vue component. * Remove unused dependencies * Fix styling --------- Co-authored-by: duncanmcclean <[email protected]>
1 parent 93dd809 commit ceb7d93

21 files changed

+1970
-1093
lines changed

package-lock.json

Lines changed: 1553 additions & 567 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44
"build": "vite build"
55
},
66
"dependencies": {
7-
"axios": "^1.12.0",
8-
"cross-env": "^7.0.2",
9-
"marked": "^14.1.3",
10-
"underscore": "^1.13.7",
11-
"uniqid": "^5.4.0",
12-
"vue": "^2.6.11"
7+
"@tailwindcss/vite": "^4.1.16",
8+
"tailwindcss": "^4.1.16",
9+
"uniqid": "^5.4.0"
1310
},
1411
"devDependencies": {
15-
"@vitejs/plugin-vue2": "^2.2.0",
16-
"laravel-vite-plugin": "^0.7.4",
17-
"vite": "^4.5.9"
12+
"@statamic/cms": "file:./vendor/statamic/cms/resources/dist-package",
13+
"laravel-vite-plugin": "^1.3.0",
14+
"vite": "^6.4.1"
1815
}
1916
}

resources/css/cp.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@import "@statamic/cms/tailwind.css";
2+
3+
@source "../js";
4+
5+
/**
6+
Borders & padding will be added by the individual destination fields.
7+
We don't want them on the parent destination fieldtype. It just acts as a container.
8+
*/
9+
.import_destination-fieldtype {
10+
@apply border-b-0 !px-0 !py-0;
11+
}

resources/js/components/CreateImportForm.vue

Lines changed: 0 additions & 88 deletions
This file was deleted.

resources/js/components/EditImportForm.vue

Lines changed: 0 additions & 145 deletions
This file was deleted.
Lines changed: 49 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,50 @@
1-
<template>
2-
<v-select
3-
searchable
4-
:options="options"
5-
:get-option-label="(option) => option.title"
6-
:get-option-key="(option) => option.handle"
7-
:value="value"
8-
:reduce="opt => opt.handle"
9-
@input="update($event)"
10-
/>
11-
</template>
12-
13-
<script>
14-
export default {
15-
mixins: [Fieldtype],
16-
17-
inject: ['storeName'],
18-
19-
mounted() {
20-
if (! this.value && this.type && (this.collection || this.taxonomy)) {
21-
this.$emit('input', this.options[0].handle);
22-
}
23-
},
24-
25-
computed: {
26-
type() {
27-
return this.$store.state.publish[this.storeName].values.destination.type;
28-
},
29-
30-
collection() {
31-
return this.$store.state.publish[this.storeName].values.destination.collection[0];
32-
},
33-
34-
taxonomy() {
35-
return this.$store.state.publish[this.storeName].values.destination.taxonomy[0];
36-
},
37-
38-
options() {
39-
if (this.type === 'entries') {
40-
return this.meta.collectionBlueprints[this.collection];
41-
}
42-
43-
if (this.type === 'terms') {
44-
return this.meta.taxonomyBlueprints[this.taxonomy];
45-
}
46-
},
47-
},
48-
49-
watch: {
50-
type() {
51-
this.$emit('input', null);
52-
},
53-
54-
collection() {
55-
this.$emit('input', this.options[0].handle);
56-
},
57-
58-
taxonomy() {
59-
this.$emit('input', this.options[0].handle);
60-
},
61-
}
62-
}
1+
<script setup>
2+
import { Fieldtype } from '@statamic/cms';
3+
import { injectPublishContext, Select } from '@statamic/cms/ui';
4+
import { computed, watch, onMounted } from 'vue';
5+
6+
const { values: publishValues } = injectPublishContext();
7+
8+
const emit = defineEmits(Fieldtype.emits);
9+
const props = defineProps(Fieldtype.props);
10+
const { expose, update } = Fieldtype.use(emit, props);
11+
defineExpose(expose);
12+
13+
const type = computed(() => publishValues.value.destination?.type);
14+
const collection = computed(() => publishValues.value.destination?.collection[0]);
15+
const taxonomy = computed(() => publishValues.value.destination?.taxonomy[0]);
16+
17+
const options = computed(() => {
18+
if (type.value === 'entries') {
19+
return props.meta.collectionBlueprints[collection.value] ?? [];
20+
}
21+
22+
if (type.value === 'terms') {
23+
return props.meta.taxonomyBlueprints[taxonomy.value] ?? [];
24+
}
25+
26+
return [];
27+
});
28+
29+
watch(() => type.value, () => update(null));
30+
watch(() => collection.value, () => update(options.value[0].handle));
31+
watch(() => taxonomy.value, () => update(options.value[0].handle));
32+
33+
onMounted(() => {
34+
if (! props.value && type.value && (collection.value || taxonomy.value)) {
35+
update(options.value[0].handle);
36+
}
37+
});
6338
</script>
39+
40+
<template>
41+
<Select
42+
v-if="options.length > 0"
43+
class="w-full"
44+
:options
45+
option-label="title"
46+
option-value="handle"
47+
:model-value="value"
48+
@update:model-value="update($event)"
49+
/>
50+
</template>

0 commit comments

Comments
 (0)