Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Oct 22, 2024
1 parent 93c462d commit a166a53
Show file tree
Hide file tree
Showing 33 changed files with 1,311 additions and 488 deletions.
2 changes: 1 addition & 1 deletion .phpunit.result.cache

Large diffs are not rendered by default.

92 changes: 92 additions & 0 deletions resources/js/components/CreateImportForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<template>
<div class="mt-3 card p-0 overflow-hidden">
<form class="p-4" @submit.prevent="save">
<h2>{{ __('New Import') }}</h2>

<publish-container
name="base"
:blueprint="blueprint"
:values="values"
:meta="meta"
:errors="errors"
:track-dirty-state="false"
@updated="values = $event"
>
<div slot-scope="{ setFieldValue, setFieldMeta }">
<div class="-mx-6">
<publish-fields
:fields="fields"
@updated="setFieldValue"
@meta-updated="setFieldMeta"
/>
</div>
</div>
</publish-container>

<div class="flex justify-center">
<button class="btn-primary" :disabled="saving">{{ __('Save & Configure') }}</button>
</div>
</form>
</div>
</template>

<script>
import axios from 'axios';
import HasInputOptions from '../../../vendor/statamic/cms/resources/js/components/fieldtypes/HasInputOptions.js';
import Mappings from "./Mappings.vue";
export default {
components: {Mappings},
mixins: [HasInputOptions],
props: {
action: String,
blueprint: Object,
fields: Array,
initialMeta: Object,
initialValues: Object,
},
data() {
return {
error: null,
errors: {},
saving: false,
meta: this.initialMeta,
values: this.initialValues,
}
},
methods: {
clearErrors() {
this.error = null;
this.errors = {};
},
save() {
this.saving = true;
this.clearErrors();
axios.post(this.action, this.values)
.then(response => {
this.saving = false;
window.location = response.data.redirect;
})
.catch(e => {
this.saving = false;
if (e.response && e.response.status === 422) {
const { message, errors } = e.response.data;
this.error = message;
this.errors = errors;
this.$toast.error(message);
return;
}
const message = data_get(e, 'response.data.message');
this.$toast.error(message || e);
});
}
}
}
</script>
86 changes: 86 additions & 0 deletions resources/js/components/EditImportForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<template>
<div>
<breadcrumb v-if="breadcrumbs" :url="breadcrumbs[0].url" :title="breadcrumbs[0].text" />

<div class="flex items-center justify-between mb-6">
<h1 v-text="title"></h1>

<div class="flex items-center space-x-4">
<button class="btn" :disabled="saving" @click="save()">{{ __('Save') }}</button>
<button class="btn-primary" :disabled="saving" @click="save(true)">{{ __('Save & Run') }}</button>
</div>
</div>

<div class="mt-3 card overflow-hidden">
<Mappings
:config="config"
:errors="errors"
:mappings-url="mappingsUrl"
@updated="config = $event"
/>
</div>
</div>
</template>

<script>
import axios from 'axios';
import Mappings from "./Mappings.vue";
export default {
components: {Mappings},
props: {
action: String,
breadcrumbs: Array,
title: String,
initialConfig: Object,
mappingsUrl: String,
},
data() {
return {
error: null,
errors: {},
saving: false,
config: this.initialConfig,
}
},
methods: {
clearErrors() {
this.error = null;
this.errors = {};
},
save(shouldRun = false) {
this.saving = true;
this.clearErrors();
axios.patch(this.action, {
mappings: this.config.mappings,
unique_key: this.config.unique_key,
run: shouldRun,
})
.then(response => {
this.saving = false;
if (shouldRun) this.$toast.success(__('Saved & Running'));
if (! shouldRun) this.$toast.success(__('Saved'));
})
.catch(e => {
this.saving = false;
if (e.response && e.response.status === 422) {
const { message, errors } = e.response.data;
this.error = message;
this.errors = errors;
this.$toast.error(message);
return;
}
const message = data_get(e, 'response.data.message');
this.$toast.error(message || e);
});
},
},
}
</script>
188 changes: 0 additions & 188 deletions resources/js/components/ImportWizard.vue

This file was deleted.

Loading

0 comments on commit a166a53

Please sign in to comment.