-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(#568): added initial entity-form update poc
- Loading branch information
Showing
13 changed files
with
155 additions
and
77 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
examples/druxt-site/components/druxt/views/filter/Default.vue
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,26 @@ | ||
<template> | ||
<div class="card"> | ||
<h2 v-text="title" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
title: { | ||
type: String, | ||
required: true | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.card { | ||
cursor: pointer; | ||
display: block; | ||
border: 1px solid lightgray; | ||
padding: 1rem; | ||
margin: 1rem 0; | ||
} | ||
</style> |
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,39 @@ | ||
<template> | ||
<div> | ||
<slot name="filters" /> | ||
<div class="items"> | ||
<DruxtEntity | ||
v-for="result of results" | ||
:key="result.id" | ||
:uuid="result.id" | ||
:type="result.type" | ||
mode="card" | ||
> | ||
<template #default="{ entity }"> | ||
<AppCard :title="entity.attributes.title" @click.native="setEntity(entity)" /> | ||
</template> | ||
</DruxtEntity> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { DruxtViewsViewMixin } from 'druxt-views' | ||
import { mapMutations } from 'vuex' | ||
export default { | ||
mixins: [DruxtViewsViewMixin], | ||
methods: { | ||
...mapMutations(['setEntity']), | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.items { | ||
display: grid; | ||
grid-template-columns: auto auto auto; | ||
column-gap: 4rem; | ||
} | ||
</style> |
32 changes: 32 additions & 0 deletions
32
examples/entity-form/components/druxt/views/filter/Default.vue
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,32 @@ | ||
<template> | ||
<div> | ||
<label :for="filter.id">{{ filter.expose.label }}:</label> | ||
|
||
<!-- Basic string field based filter. --> | ||
<input | ||
v-if="filter.plugin_id === 'string'" | ||
:id="filter.id" | ||
v-model="model" | ||
/> | ||
|
||
<!-- Select list based filter. --> | ||
<select v-else :id="filter.id"> | ||
<option v-for="option of options" :key="option">{{ option }}</option> | ||
</select> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { DruxtViewsFilterMixin } from 'druxt-views' | ||
export default { | ||
mixins: [DruxtViewsFilterMixin], | ||
computed: { | ||
// @TODO - build available filter options based on configuration. | ||
options: () => { | ||
return [] | ||
} | ||
} | ||
} | ||
</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
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 |
---|---|---|
@@ -1,31 +1,34 @@ | ||
<template> | ||
<div> | ||
<h1>DruxtEntityForm example:</h1> | ||
|
||
<h2>Contact form - Basic</h2> | ||
<pre><code><DruxtEntityForm type="contact_message--feedback" /></code></pre> | ||
<!-- If user is not logged in, present login form --> | ||
<div v-if="!isLoggedIn"> | ||
@TODO - Login UI | ||
</div> | ||
|
||
<pre v-if="response"> | ||
<code>{{ JSON.stringify(response, null, ' ') }}</code> | ||
</pre> | ||
<!-- If logged in, but no entity is set, render the Content view --> | ||
<div v-else-if="!entity"> | ||
<DruxtView view-id="content" /> | ||
</div> | ||
|
||
<DruxtEntityForm | ||
type="contact_message--feedback" | ||
@error="setResponse" | ||
@submit="setResponse" | ||
/> | ||
<div v-else> | ||
<button @click="clearEntity">Close</button> | ||
<DruxtEntityForm :uuid="entity.id" :type="entity.type" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { mapState, mapMutations } from 'vuex' | ||
export default { | ||
data: () => ({ | ||
response: null, | ||
}), | ||
methods: { | ||
setResponse(response) { | ||
this.response = response; | ||
}, | ||
computed: { | ||
isLoggedIn: () => true, | ||
...mapState({ | ||
entity: state => state.entity | ||
}) | ||
}, | ||
}; | ||
methods: { | ||
...mapMutations(['clearEntity']) | ||
} | ||
} | ||
</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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const state = () => ({ | ||
entity: undefined, | ||
}) | ||
|
||
export const mutations = { | ||
clearEntity(state) { | ||
state.entity = undefined | ||
}, | ||
|
||
setEntity(state, entity) { | ||
state.entity = entity | ||
} | ||
} |
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