-
-
Notifications
You must be signed in to change notification settings - Fork 541
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '5.x' of https://github.com/statamic/cms into starter-ki…
…t-export-package-folder
- Loading branch information
Showing
105 changed files
with
2,193 additions
and
770 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
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,67 @@ | ||
import modal from './modal'; | ||
|
||
export default class FieldAction { | ||
#payload; | ||
#run; | ||
#visible; | ||
#visibleWhenReadOnly; | ||
#icon; | ||
#quick; | ||
#confirm; | ||
|
||
constructor(action, payload) { | ||
this.#payload = payload; | ||
this.#run = action.run; | ||
this.#confirm = action.confirm; | ||
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; | ||
} | ||
|
||
async run() { | ||
let payload = {...this.#payload}; | ||
|
||
if (this.#confirm) { | ||
const confirmation = await modal(this.#modalProps()); | ||
if (!confirmation.confirmed) return; | ||
payload = {...payload, confirmation}; | ||
} | ||
|
||
const response = this.#run(payload); | ||
|
||
if (response instanceof Promise) { | ||
const progress = this.#payload.vm.$progress; | ||
const name = this.#payload.fieldPathPrefix ?? this.#payload.handle; | ||
progress.loading(name, true); | ||
response.finally(() => progress.loading(name, false)); | ||
} | ||
} | ||
|
||
#modalProps() { | ||
let props = this.#confirm === true ? {} : {...this.#confirm}; | ||
|
||
if (! props.title) { | ||
props.title = this.title; | ||
} | ||
|
||
return props; | ||
} | ||
} |
Oops, something went wrong.