Skip to content

Commit

Permalink
lots of changes: swapped dropdown and contextmenu icons, contextmenu …
Browse files Browse the repository at this point in the history
…will now open on click and close when unfocused or an action is taken on the menu. ContextMenu styling changes
  • Loading branch information
JmScherer committed Dec 15, 2023
1 parent f8bdee4 commit f2f1a5e
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 85 deletions.
47 changes: 12 additions & 35 deletions frontend/src/components/AnalysisView/DiscussionPost.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
{{ timestamp }}
</div>
<ul v-if="isUser" class="actions-menu">
<!-- <DropDownMenu :actions="this.postActions">
<font-awesome-icon class="header-icon" icon="caret-down" size="xl" />
</DropDownMenu> -->
<ContextMenu :actions="this.postActions" :context_id="id">
<font-awesome-icon class="header-icon" icon="caret-down" size="xl" />
<ContextMenu :actions="actions" :context_id="id">
<font-awesome-icon class="header-icon" icon="ellipsis-vertical" size="xl" />
</ContextMenu>
</ul>
</div>
Expand All @@ -21,14 +18,12 @@
</template>

<script>
import DropDownMenu from '@/components/DropDownMenu.vue';
import ContextMenu from '@/components/ContextMenu.vue';
export default {
name: 'discussion-post',
components: {
DropDownMenu,
ContextMenu
ContextMenu,
},
props: {
id: {
Expand Down Expand Up @@ -59,39 +54,19 @@ export default {
},
},
userClientId: {
type: String
}
},
data: function() {
return {
postActions: [
{
icon: 'pencil',
text: 'Edit',
operation: () => {
console.log("Editing post")
},
},
{
divider: true
},
{
icon: 'xmark',
text: 'Delete',
operation: () => {
console.log("Deleting post")
},
},
]
}
type: String,
},
actions: {
type: Array,
},
},
computed: {
timestamp: function() {
return new Date(this.publish_timestamp).toUTCString();
},
isUser: function() {
return this.userClientId == this.author_id
}
return this.userClientId == this.author_id;
},
},
};
</script>
Expand Down Expand Up @@ -139,6 +114,8 @@ export default {
.header-icon {
color: var(--rosalution-purple-300);
cursor: pointer;
padding: var(--p-5)
}
</style>
11 changes: 9 additions & 2 deletions frontend/src/components/AnalysisView/DiscussionSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
:attachments="discussion.attachments"
:thread="discussion.thread"
:userClientId="userClientId"
:actions="actions"
/>
</div>
</div>
Expand All @@ -77,8 +78,14 @@ export default {
},
},
userClientId: {
type: String
}
type: String,
},
actions: {
type: Array,
default: () => {
return [];
},
},
},
data: function() {
return {
Expand Down
80 changes: 37 additions & 43 deletions frontend/src/components/ContextMenu.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<template>
<li>
<label :for="context_id">
<slot></slot>
</label>
<input type="checkbox" :id="context_id" />
<li tabindex="1" ref="contextRef">
<slot></slot>
<ul class="grey-rounded-menu drop-down-content">
<li v-for="action in actions" :key="action.text" @click="action.operation()">
<li v-for="action in actions" :key="action.text" @click="this.runAction(action.operation)">
<span> {{ action.text }} </span>
<font-awesome-icon v-if="action.icon" :icon="action.icon" size="lg" class="right-side-icon" />
</li>
Expand All @@ -15,21 +12,25 @@

<script>
export default {
name: 'context-menu',
props: {
actions: {
type: Array,
validator: (prop) => prop.every(
(action) => action.text !== undefined || action.divider,
)
},
context_id: String,
name: 'context-menu',
props: {
actions: {
type: Array,
validator: (prop) => prop.every(
(action) => action.text !== undefined || action.divider,
),
},
computed: {
context_toggle() {
return this.context_id.toLowerCase() + '_menu'
}
}
context_id: String,
},
methods: {
runAction(actionOperation) {
actionOperation();
this.closeContext();
},
closeContext() {
this.$refs.contextRef.blur();
},
},
};
</script>

Expand All @@ -42,17 +43,9 @@ hr {
border-radius: var(--content-border-radius);
background-color: var(--rosalution-white);
border: 3px solid var(--rosalution-grey-000);
width: 230px;
width: 175px;
padding: .75rem;
}
.drop-down-content {
text-align: right;
}
.right-side-icon {
margin-left: var(--p-8);
margin-bottom: 0.12rem;
margin-right: var(--p-16)
}
ul li ul {
Expand All @@ -69,23 +62,24 @@ ul li ul:hover li:hover {
background-color: var(--rosalution-purple-100);
}
label {
cursor: pointer;
}
input[type="checkbox"] {
display: none;
ul li ul li {
clear: both;
width: 100%;
line-height: 2rem;
}
/* li input[type=checkbox]:checked ~ ul {
li:focus ul {
visibility: visible;
opacity: 1;
display: block;
} */
}
input[type=checkbox]:checked + ul {
visibility: visible;
opacity: 1;
display: block;
.drop-down-content {
text-align: right;
}
.right-side-icon {
margin-left: var(--p-8);
margin-bottom: 0.12rem;
}
</style>
</style>
2 changes: 1 addition & 1 deletion frontend/src/components/RosalutionHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</router-link>
</drop-down-menu>
<drop-down-menu v-if="actionsExist" :actions="actions" data-test="user-menu">
<font-awesome-icon class="header-icon" icon="ellipsis-vertical" size="xl" />
<font-awesome-icon class="header-icon" icon="bars" size="xl" />
</drop-down-menu>
</ul>
</div>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
faAsterisk, faPause, faCheck, faX, faUser, faUsers, faUserGroup, faCalendar, faBookOpen, faList, faLayerGroup,
faBoxArchive, faQuestion, faClock, faClipboardCheck, faMagnifyingGlass, faChevronDown, faChevronRight,
faUpRightFromSquare, faCirclePlus, faPencil, faEllipsisVertical, faLink, faXmark, faUserDoctor, faPaperclip, faPlus,
faAnglesRight, faFileImage, faFileCirclePlus, faMountainSun, faArrowUp, faArrowDown, faCaretDown
faAnglesRight, faFileImage, faFileCirclePlus, faMountainSun, faArrowUp, faArrowDown, faCaretDown, faBars,
} from '@fortawesome/free-solid-svg-icons';
import {
faCopy, faFile, faComment, faCircleCheck, faCircleQuestion, faCircleXmark, faImages,
Expand All @@ -35,7 +35,7 @@ library.add(
faLayerGroup, faBoxArchive, faQuestion, faClock, faClipboardCheck, faChevronDown, faChevronRight,
faUpRightFromSquare, faCopy, faCirclePlus, faFile, faComment, faPencil, faEllipsisVertical, faLink, faXmark,
faUserDoctor, faPaperclip, faPlus, faAnglesRight, faCircleCheck, faCircleQuestion, faCircleXmark, faImages,
faFileImage, faFileCirclePlus, faMountainSun, faArrowUp, faArrowDown, faCaretDown
faFileImage, faFileCirclePlus, faMountainSun, faArrowUp, faArrowDown, faCaretDown, faBars,
);

// The NotFoundView should always be last because it's an ordered array.
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/stores/authStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const authStore = {
this.state.email = user['email'];
this.state.roles.push(user['scope']);
this.state.clientId = user['client_id'];

user['client_secret'] ? this.state.clientSecret = user['client_secret'] : '';
},
getUser() {
Expand Down
20 changes: 19 additions & 1 deletion frontend/src/views/AnalysisView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
id="Discussion"
:discussions="this.discussions"
:userClientId="auth.getClientId()"
:actions="this.discussionContextActions"
@discussion:new-post="this.addDiscussionPost"
/>
<SupplementalFormList
Expand Down Expand Up @@ -201,7 +202,24 @@ export default {
return actionChoices;
},
discussionContextActions() {
return [
{
icon: 'pencil',
text: 'Edit',
operation: () => {
console.log('Editing Discussion Post');
},
},
{
icon: 'xmark',
text: 'Delete',
operation: () => {
console.log('Deleting Discussion Post');
},
},
];
},
sectionsList() {
return this.analysis.sections;
},
Expand Down

0 comments on commit f2f1a5e

Please sign in to comment.