-
Notifications
You must be signed in to change notification settings - Fork 601
make widget operations dynamic to add custom ones #4897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 22 commits
f4b3058
3844e0c
2c807f3
98057e7
d64159e
9c461d5
d4d0592
43ab477
d9b6c97
4439236
0113abe
66c74ab
5e8ac05
d9b0ec0
1986cb0
4075b2a
f922415
86df98d
f805286
2e972b9
f7dbb73
64232c1
97616e3
4f845df
f6d2fce
6cd511f
0e36809
2df810c
7ba8322
c5a77da
6c20ec3
28e54e8
856be19
c3c40eb
91d2100
6dbd218
4d9e8e9
dfdac3f
b6089b5
f477534
9bce775
125e1de
ba29ff0
408a265
e00da1d
1bf4d4f
601a607
4d578fc
5873267
20e8780
8486ced
472902d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
class="apos-admin-bar__btn" | ||
:modifiers="['no-motion']" | ||
role="menuitem" | ||
@click="emitEvent('@apostrophecms/page:manager')" | ||
@click="emitEvent({ action: '@apostrophecms/page:manager' })" | ||
/> | ||
</li> | ||
<li | ||
|
@@ -42,7 +42,7 @@ | |
:modifiers="['no-motion']" | ||
class="apos-admin-bar__btn" | ||
role="menuitem" | ||
@click="emitEvent(item.action)" | ||
@click="emitEvent(item)" | ||
/> | ||
</li> | ||
<li | ||
|
@@ -85,7 +85,7 @@ | |
:label="item.label" | ||
:action="item.action" | ||
:state="trayItemState[item.name] ? [ 'active' ] : []" | ||
@click="emitEvent(item.action)" | ||
@click="emitEvent(item)" | ||
/> | ||
</template> | ||
</li> | ||
|
@@ -122,10 +122,9 @@ export default { | |
} | ||
}, | ||
async mounted() { | ||
apos.bus.$on('admin-menu-click', this.onAdminMenuClick); | ||
|
||
const itemsSet = klona(this.items); | ||
this.menuItems = itemsSet.filter(item => !(item.options && item.options.contextUtility)) | ||
this.menuItems = itemsSet | ||
.filter(item => !(item.options && item.options.contextUtility)) | ||
.map(item => { | ||
if (item.items) { | ||
item.items.forEach(subitem => { | ||
|
@@ -148,12 +147,26 @@ export default { | |
}); | ||
}, | ||
methods: { | ||
emitEvent(name) { | ||
apos.bus.$emit('admin-menu-click', name); | ||
emitEvent(item) { | ||
apos.bus.$emit('admin-menu-click', item.action); | ||
|
||
// Maintain a knowledge of which tray item toggles are active | ||
const trayItem = this.trayItems.find(trayItem => trayItem.name === item.action); | ||
|
||
if (trayItem && trayItem.options.toggle) { | ||
this.trayItemState = { | ||
...this.trayItemState, | ||
[item.action]: !this.trayItemState[item.action] | ||
}; | ||
} | ||
Comment on lines
+153
to
+161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. block moved from the late |
||
}, | ||
trayItemTooltip(item) { | ||
if (item.options.toggle) { | ||
if (this.trayItemState[item.name] && item.options.tooltip && item.options.tooltip.deactivate) { | ||
if ( | ||
this.trayItemState[item.name] && | ||
item.options.tooltip && | ||
item.options.tooltip.deactivate | ||
) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. linter |
||
return { | ||
content: item.options.tooltip.deactivate, | ||
placement: 'bottom' | ||
|
@@ -169,17 +182,6 @@ export default { | |
} else { | ||
return item.options.tooltip; | ||
} | ||
}, | ||
// Maintain a knowledge of which tray item toggles are active | ||
onAdminMenuClick(e) { | ||
const name = e.itemName || e; | ||
const trayItem = this.trayItems.find(item => item.name === name); | ||
if (trayItem && trayItem.options.toggle) { | ||
this.trayItemState = { | ||
...this.trayItemState, | ||
[name]: !this.trayItemState[name] | ||
}; | ||
} | ||
} | ||
} | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,8 +43,8 @@ export default { | |
} | ||
}, | ||
methods: { | ||
emitEvent(name) { | ||
apos.bus.$emit('admin-menu-click', name); | ||
emitEvent(item) { | ||
apos.bus.$emit('admin-menu-click', item.action); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could, but in the end, the component that listens to |
||
} | ||
} | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,8 @@ | |
> | ||
<!-- | ||
TODO: Each div at this level serves as a discrete context menu state | ||
Modules should be able to provide their own menus here to complete tasks specific to them. | ||
Modules should be able to provide their own menus here to complete | ||
tasks specific to them. | ||
Comment on lines
+9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. linter |
||
It might also be worth breaking up the core menus into their own vue components to | ||
further illustrate this concept. | ||
--> | ||
|
@@ -107,7 +108,11 @@ export default { | |
if (this.canPublish) { | ||
if (this.context.lastPublishedAt) { | ||
// Document went from unpublished to published and has nothing staged | ||
if (this.hasBeenPublishedThisPageload && !this.readyToPublish && this.hasBeenPublishedButNotUpdated) { | ||
if ( | ||
this.hasBeenPublishedThisPageload && | ||
!this.readyToPublish && | ||
this.hasBeenPublishedButNotUpdated | ||
) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. linter |
||
return 'apostrophe:published'; | ||
// Document *has* had changes published this page load, but nothing staged now | ||
} else if (this.hasBeenPublishedThisPageload && !this.readyToPublish) { | ||
|
@@ -135,7 +140,11 @@ export default { | |
} | ||
}, | ||
publishTooltip() { | ||
if (this.canPublish && this.context.lastPublishedAt && !this.hasBeenPublishedThisPageload) { | ||
if ( | ||
this.canPublish && | ||
this.context.lastPublishedAt && | ||
!this.hasBeenPublishedThisPageload | ||
) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. linter |
||
return { | ||
content: 'apostrophe:updateTooltip', | ||
placement: 'bottom' | ||
|
@@ -145,10 +154,13 @@ export default { | |
return false; | ||
}, | ||
isAutopublished() { | ||
return this.context._aposAutopublish ?? (window.apos.modules[this.context.type].autopublish || false); | ||
return this.context._aposAutopublish ?? | ||
(window.apos.modules[this.context.type].autopublish || false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. linter |
||
}, | ||
hasBeenPublishedThisPageload() { | ||
return (this.context.lastPublishedAt > this.mountedAt) || ((this.context.submitted && this.context.submitted.at) > this.mountedAt); | ||
return ( | ||
this.context.lastPublishedAt > this.mountedAt) || | ||
((this.context.submitted && this.context.submitted.at) > this.mountedAt); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. linter |
||
}, | ||
canSwitchToEditMode() { | ||
return !this.editMode; | ||
|
@@ -188,9 +200,6 @@ export default { | |
this.hasBeenPublishedButNotUpdated = false; | ||
} | ||
this.$emit('publish'); | ||
}, | ||
emitEvent(name) { | ||
apos.bus.$emit('admin-menu-click', name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused |
||
} | ||
} | ||
}; | ||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -124,7 +124,8 @@ export default { | |||||||
return window.apos.adminBar; | ||||||||
}, | ||||||||
isAutopublished() { | ||||||||
return this.context._aposAutopublish ?? (window.apos.modules[this.context.type].autopublish || false); | ||||||||
return this.context._aposAutopublish ?? | ||||||||
(window.apos.modules[this.context.type].autopublish || false); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. linter |
||||||||
} | ||||||||
}, | ||||||||
mounted() { | ||||||||
|
@@ -137,11 +138,11 @@ export default { | |||||||
togglePublishDraftMode() { | ||||||||
if (this.canTogglePublishDraftMode) { | ||||||||
const mode = this.draftMode === 'draft' ? 'published' : 'draft'; | ||||||||
this.switchDraftMode(mode); | ||||||||
this.$emit('switch-draft-mode', mode); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
} | ||||||||
}, | ||||||||
switchDraftMode(mode) { | ||||||||
this.$emit('switch-draft-mode', mode); | ||||||||
switchDraftMode(item) { | ||||||||
this.$emit('switch-draft-mode', item.action); | ||||||||
} | ||||||||
} | ||||||||
}; | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linter