-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: support minimum version v5.1.4
- Loading branch information
Showing
16 changed files
with
130 additions
and
129 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
Large diffs are not rendered by default.
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,47 @@ | ||
import { reactive, ref, watch } from 'vue' | ||
|
||
export function usePanelVisibility( | ||
panel = { attribute: 'default', fields: [] }, | ||
emitter = null | ||
) { | ||
const visibleFieldsForPanel = {} | ||
const visibleFieldsCount = ref(0) | ||
|
||
panel.fields.forEach(field => { | ||
visibleFieldsForPanel[field.attribute] = field.visible | ||
}) | ||
|
||
const handleFieldShown = field => { | ||
visibleFieldsForPanel[field] = true | ||
|
||
if (emitter !== null) { | ||
emitter('field-shown', field) | ||
} | ||
|
||
syncVisibleFieldsCount(visibleFieldsForPanel) | ||
} | ||
|
||
const handleFieldHidden = field => { | ||
visibleFieldsForPanel[field] = false | ||
|
||
if (emitter !== null) { | ||
emitter('field-shown', field) | ||
} | ||
|
||
syncVisibleFieldsCount(visibleFieldsForPanel) | ||
} | ||
|
||
const syncVisibleFieldsCount = fields => { | ||
visibleFieldsCount.value = Object.values(fields).filter( | ||
visible => visible === true | ||
).length | ||
} | ||
|
||
syncVisibleFieldsCount(visibleFieldsForPanel) | ||
|
||
return { | ||
handleFieldShown, | ||
handleFieldHidden, | ||
visibleFieldsCount, | ||
} | ||
} |
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,54 @@ | ||
import { mapProps } from './propTypes' | ||
import filled from '../util/filled' | ||
|
||
export default { | ||
props: mapProps([ | ||
'field', | ||
'resourceName', | ||
'resourceId', | ||
'viaResource', | ||
'viaResourceId', | ||
'viaRelationship', | ||
'relatedResourceName', | ||
'relatedResourceId', | ||
'mode', | ||
]), | ||
|
||
methods: { | ||
async fetchPreviewContent(value) { | ||
Nova.$progress.start() | ||
|
||
let editMode = this.resourceId == null ? 'create' : 'update' | ||
let endpoint = | ||
this.resourceId == null | ||
? `/nova-api/${this.resourceName}/field/${this.field.attribute}/preview` | ||
: `/nova-api/${this.resourceName}/${this.resourceId}/field/${this.field.attribute}/preview` | ||
|
||
if (filled(this.relatedResourceName)) { | ||
editMode = this.relatedResourceId == null ? 'attach' : 'update-attached' | ||
|
||
endpoint = `${endpoint}/${this.relatedResourceName}` | ||
} | ||
|
||
const { | ||
data: { preview }, | ||
} = await Nova.request().post( | ||
endpoint, | ||
{ value }, | ||
{ | ||
params: { | ||
editing: true, | ||
editMode: editMode, | ||
viaResource: this.viaResource, | ||
viaResourceId: this.viaResourceId, | ||
viaRelationship: this.viaRelationship, | ||
}, | ||
} | ||
) | ||
|
||
Nova.$progress.done() | ||
|
||
return preview | ||
}, | ||
}, | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 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