-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "Blueprint" option when configuring entry/term imports (#64)
* Add "Blueprint" dropdown when configuring imports * Hide mapping table after changing the blueprint. * The mapping table should use the configured blueprint. * Created entries/terms should use the configured blueprint. * Make it a little more user friendly. * Make everything work for existing imports. * The blueprint should be required. * Instructions. * wip * Add `blueprint` key in tests * Add tests. * Clear the Blink cache. * Fix styling * wip * Make it searchable. It makes the UI a little nicer. --------- Co-authored-by: duncanmcclean <[email protected]>
- Loading branch information
1 parent
fdea314
commit 97da8e8
Showing
10 changed files
with
228 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<template> | ||
<v-select | ||
searchable | ||
:options="options" | ||
:get-option-label="(option) => option.title" | ||
:get-option-key="(option) => option.handle" | ||
:value="value" | ||
:reduce="opt => opt.handle" | ||
@input="update($event)" | ||
/> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
mixins: [Fieldtype], | ||
inject: ['storeName'], | ||
mounted() { | ||
if (! this.value && this.type && (this.collection || this.taxonomy)) { | ||
this.$emit('input', this.options[0].handle); | ||
} | ||
}, | ||
computed: { | ||
type() { | ||
return this.$store.state.publish[this.storeName].values.destination.type; | ||
}, | ||
collection() { | ||
return this.$store.state.publish[this.storeName].values.destination.collection[0]; | ||
}, | ||
taxonomy() { | ||
return this.$store.state.publish[this.storeName].values.destination.taxonomy[0]; | ||
}, | ||
options() { | ||
if (this.type === 'entries') { | ||
return this.meta.collectionBlueprints[this.collection]; | ||
} | ||
if (this.type === 'terms') { | ||
return this.meta.taxonomyBlueprints[this.taxonomy]; | ||
} | ||
}, | ||
}, | ||
watch: { | ||
type() { | ||
this.$emit('input', null); | ||
}, | ||
collection() { | ||
this.$emit('input', this.options[0].handle); | ||
}, | ||
taxonomy() { | ||
this.$emit('input', this.options[0].handle); | ||
}, | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import CreateImportForm from "./components/CreateImportForm.vue"; | ||
import EditImportForm from "./components/EditImportForm.vue"; | ||
import ImportsListing from "./components/ImportsListing.vue"; | ||
import BlueprintFieldtype from "./components/Fieldtypes/BlueprintFieldtype.vue"; | ||
import ImportMappingsFieldtype from "./components/Fieldtypes/ImportMappingsFieldtype.vue"; | ||
|
||
Statamic.$components.register('create-import-form', CreateImportForm); | ||
Statamic.$components.register('edit-import-form', EditImportForm); | ||
Statamic.$components.register('imports-listing', ImportsListing); | ||
Statamic.$components.register('blueprint-fieldtype', BlueprintFieldtype); | ||
Statamic.$components.register('import_mappings-fieldtype', ImportMappingsFieldtype); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Statamic\Importer\Fieldtypes; | ||
|
||
use Statamic\Facades\Collection; | ||
use Statamic\Facades\Taxonomy; | ||
use Statamic\Fields\Fieldtype; | ||
|
||
class BlueprintFieldtype extends Fieldtype | ||
{ | ||
public function preload() | ||
{ | ||
return [ | ||
'collectionBlueprints' => Collection::all()->mapWithKeys(function ($collection) { | ||
return [$collection->handle() => $collection->entryBlueprints()->values()]; | ||
})->all(), | ||
'taxonomyBlueprints' => Taxonomy::all()->mapWithKeys(function ($taxonomy) { | ||
return [$taxonomy->handle() => $taxonomy->termBlueprints()->values()]; | ||
})->all(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.