-
-
Notifications
You must be signed in to change notification settings - Fork 549
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jason Varga <jason@pixelfear.com>
- Loading branch information
1 parent
a272414
commit 63be821
Showing
34 changed files
with
681 additions
and
153 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<template> | ||
<div> | ||
<button | ||
v-for="action in actions" | ||
@click="run(action)" | ||
v-text="action.title" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: ['actions'], | ||
inject: ['popover'], | ||
methods: { | ||
run(action) { | ||
action.run(); | ||
this.popover.vm.close(); | ||
}, | ||
} | ||
} | ||
</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,38 @@ | ||
export default class FieldAction { | ||
#payload; | ||
#run; | ||
#visible; | ||
#visibleWhenReadOnly; | ||
#icon; | ||
#quick; | ||
|
||
constructor(action, payload) { | ||
this.#payload = payload; | ||
this.#run = action.run; | ||
this.#visible = action.visible ?? true; | ||
this.#visibleWhenReadOnly = action.visibleWhenReadOnly ?? false; | ||
this.#icon = action.icon ?? 'image'; | ||
this.#quick = action.quick ?? false; | ||
this.title = action.title; | ||
} | ||
|
||
get visible() { | ||
if (this.#payload.isReadOnly && !this.#visibleWhenReadOnly) { | ||
return false; | ||
} | ||
|
||
return typeof this.#visible === 'function' ? this.#visible(this.#payload) : this.#visible; | ||
} | ||
|
||
get quick() { | ||
return typeof this.#quick === 'function' ? this.#quick(this.#payload) : this.#quick; | ||
} | ||
|
||
get icon() { | ||
return typeof this.#icon === 'function' ? this.#icon(this.#payload) : this.#icon; | ||
} | ||
|
||
run() { | ||
this.#run(this.#payload); | ||
} | ||
} |
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,21 @@ | ||
import uid from 'uniqid'; | ||
|
||
class FieldActions { | ||
constructor() { | ||
this.actions = {}; | ||
} | ||
|
||
add(name, action) { | ||
if (this.actions[name] === undefined) { | ||
this.actions[name] = []; | ||
} | ||
|
||
this.actions[name].push(action); | ||
} | ||
|
||
get(name) { | ||
return this.actions[name] || []; | ||
} | ||
} | ||
|
||
export default FieldActions; |
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,36 @@ | ||
<template> | ||
<div class="field-dropdown"> | ||
<div class="quick-list"> | ||
<div class="quick-list-content"> | ||
<a | ||
v-for="(action, index) in actions.filter(a => a.quick)" | ||
:key="index" | ||
@click="action.run()" | ||
v-tooltip="action.title" | ||
> | ||
<svg-icon :name="action.icon" class="h-3 w-3" /> | ||
</a> | ||
</div> | ||
<dropdown-list placement="left-start" :offset="[7, -3]"> | ||
<dropdown-actions :actions="actions" /> | ||
</dropdown-list> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import DropdownActions from '../field-actions/DropdownActions.vue'; | ||
export default { | ||
components: { | ||
DropdownActions | ||
}, | ||
props: { | ||
actions: { | ||
type: Array | ||
} | ||
} | ||
} | ||
</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,26 @@ | ||
import FieldAction from './FieldAction'; | ||
|
||
export default { | ||
|
||
computed: { | ||
|
||
fieldActions() { | ||
return [ | ||
...this.$fieldActions.get(this.$options.name), | ||
...this.internalFieldActions | ||
] | ||
.map(action => new FieldAction(action, this.fieldActionPayload)) | ||
.filter(action => action.visible); | ||
}, | ||
|
||
internalFieldActions() { | ||
return []; | ||
}, | ||
|
||
fieldActionPayload() { | ||
return {}; | ||
}, | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.