Skip to content

feat: Add UI elements to modify navigation display #1295

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

Merged
merged 18 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
enh: use checkbox for default nav display mode
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
  • Loading branch information
enjeck committed Jan 4, 2025
commit bd37dafd0b836dcd41339e6c703ba97b4dced8f3
44 changes: 23 additions & 21 deletions src/modules/modals/CreateContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,12 @@
<NcContextResource :resources.sync="resources" :receivers.sync="receivers" />
</div>
<div class="row space-T">
<div>
{{ t('tables', 'Navigation bar display') }}
</div>
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_HIDDEN"
name="NAV_ENTRY_MODE_HIDDEN" type="radio">
Hide navigation entry for everybody
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_RECIPIENTS"
name="NAV_ENTRY_MODE_RECIPIENTS" type="radio">
Show navigation entry for everybody, except me
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_ALL" name="NAV_ENTRY_MODE_ALL"
type="radio">
Show navigation entry for everybody
</NcCheckboxRadioSwitch>
<br>
<NcActionCheckbox :checked="showInNavigationDefault" @change="updateDisplayMode">
Show in app list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be translatable

</NcActionCheckbox>
<p class="nav-display-subtext">
This can be overridden by a per-account preference
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be translatable

</p>
</div>
<div class="row space-R row space-T">
<div class="fix-col-4 end">
Expand All @@ -72,7 +62,7 @@
</template>

<script>
import { NcDialog, NcButton, NcIconSvgWrapper, NcCheckboxRadioSwitch } from '@nextcloud/vue'
import { NcDialog, NcButton, NcIconSvgWrapper, NcActionCheckbox } from '@nextcloud/vue'
import { showError } from '@nextcloud/dialogs'
import '@nextcloud/dialogs/style.css'
import NcContextResource from '../../shared/components/ncContextResource/NcContextResource.vue'
Expand All @@ -90,7 +80,7 @@ export default {
NcButton,
NcIconSvgWrapper,
NcContextResource,
NcCheckboxRadioSwitch,
NcActionCheckbox,
},
mixins: [svgHelper, permissionBitmask],
props: {
Expand All @@ -111,7 +101,7 @@ export default {
description: '',
resources: [],
receivers: [],
displayMode: 'NAV_ENTRY_MODE_HIDDEN',
showInNavigationDefault: false,
}
},
watch: {
Expand Down Expand Up @@ -181,19 +171,23 @@ export default {
isUser: true,
key: 'user-' + getCurrentUser().uid,
})
const res = await this.$store.dispatch('insertNewContext', { data, previousReceivers: [], receivers: this.receivers, displayMode: NAV_ENTRY_MODE[this.displayMode] })
const displayMode = this.showInNavigation ? 'NAV_ENTRY_MODE_ALL' : 'NAV_ENTRY_MODE_HIDDEN'
const res = await this.$store.dispatch('insertNewContext', { data, previousReceivers: [], receivers: this.receivers, displayMode: NAV_ENTRY_MODE[displayMode] })
if (res) {
return res.id
} else {
showError(t('tables', 'Could not create new application'))
}
},
updateDisplayMode() {
this.showInNavigation = !this.showInNavigation
},
reset() {
this.title = ''
this.errorTitle = false
this.setIcon(this.randomIcon())
this.customTitleChosen = false
this.displayMode = 'NAV_ENTRY_MODE_HIDDEN'
this.showInNavigationDefault = false
},
},
}
Expand All @@ -207,5 +201,13 @@ export default {
display: inline-flex;
align-items: center;
}

.nav-display-subtext {
color: var(--color-text-maxcontrast)
}

li {
list-style: none;
}
}
</style>
53 changes: 29 additions & 24 deletions src/modules/modals/EditContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,14 @@
<NcContextResource :resources.sync="resources" :receivers.sync="receivers" />
</div>
<div class="row space-T">
<div>
{{ t('tables', 'Navigation bar display') }}
</div>
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_HIDDEN"
name="NAV_ENTRY_MODE_HIDDEN" type="radio">
Hide navigation entry for everybody
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_RECIPIENTS"
name="NAV_ENTRY_MODE_RECIPIENTS" type="radio">
Show navigation entry for everybody, except me
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch :checked.sync="displayMode" value="NAV_ENTRY_MODE_ALL" name="NAV_ENTRY_MODE_ALL"
type="radio">
Show navigation entry for everybody
</NcCheckboxRadioSwitch>
<br>
<NcActions>
<NcActionCheckbox :checked="showInNavigationDefault" @change="updateDisplayMode">
Show in app list
</NcActionCheckbox>
</NcActions>
<p class="nav-display-subtext">
This can be overridden by a per-account preference
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be translatable

</p>
</div>
<div class="row space-T">
<div class="fix-col-4 space-T justify-between">
Expand All @@ -79,7 +71,7 @@
</template>

<script>
import { NcDialog, NcButton, NcIconSvgWrapper, NcCheckboxRadioSwitch } from '@nextcloud/vue'
import { NcDialog, NcButton, NcIconSvgWrapper, NcActionCheckbox } from '@nextcloud/vue'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { getCurrentUser } from '@nextcloud/auth'
import '@nextcloud/dialogs/style.css'
Expand All @@ -100,7 +92,7 @@ export default {
NcIconPicker,
NcIconSvgWrapper,
NcContextResource,
NcCheckboxRadioSwitch,
NcActionCheckbox,
},
mixins: [svgHelper, permissionBitmask, permissionsMixin],
props: {
Expand Down Expand Up @@ -129,7 +121,7 @@ export default {
PERMISSION_UPDATE,
PERMISSION_DELETE,
prepareDeleteContext: false,
displayMode: 'NAV_ENTRY_MODE_HIDDEN', // TODO: get the actual saved display mode
showInNavigationDefault: false,
}
},
computed: {
Expand All @@ -154,6 +146,7 @@ export default {
this.description = context.description
this.resources = context ? this.getContextResources(context) : []
this.receivers = context ? this.getContextReceivers(context) : []
this.showInNavigationDefault = this.getNavDisplay(context)
}
},
},
Expand Down Expand Up @@ -194,7 +187,8 @@ export default {
isUser: true,
key: 'user-' + getCurrentUser().uid,
})
const res = await this.$store.dispatch('updateContext', { id: this.contextId, data, previousReceivers: Object.values(context.sharing), receivers: this.receivers })
const displayMode = this.showInNavigation ? 'NAV_ENTRY_MODE_ALL' : 'NAV_ENTRY_MODE_HIDDEN'
const res = await this.$store.dispatch('updateContext', { id: this.contextId, data, previousReceivers: Object.values(context.sharing), receivers: this.receivers, displayMode: NAV_ENTRY_MODE[displayMode] })
if (res) {
showSuccess(t('tables', 'Updated application "{contextTitle}".', { contextTitle: this.title }))
this.actionCancel()
Expand All @@ -210,15 +204,15 @@ export default {
this.resources = context ? this.getContextResources(context) : []
this.receivers = context ? this.getContextReceivers(context) : []
this.prepareDeleteContext = false
this.showInNavigationDefault = this.getNavDisplay(context)
},
getDisplayMode(context) {
getNavDisplay(context) {
const shares = Object.keys(context.sharing || {})
if (shares.length) {
print('vals', context.sharing[shares[0]])
const displayMode = context.sharing[shares[0]].display_mode_default
return Object.keys(NAV_ENTRY_MODE).find(key => NAV_ENTRY_MODE[key] === displayMode)
return displayMode !== 0
}
return 'NAV_ENTRY_MODE_HIDDEN'
return false
},
getContextReceivers(context) {
let sharing = Object.values(context.sharing)
Expand Down Expand Up @@ -276,6 +270,9 @@ export default {
}

},
updateDisplayMode() {
this.showInNavigation = !this.showInNavigation
},
actionTransfer() {
emit('tables:context:edit', null)
emit('tables:context:transfer', this.localContext)
Expand All @@ -296,4 +293,12 @@ export default {
padding-inline: 0 !important;
max-width: 100%;
}

.nav-display-subtext {
color: var(--color-text-maxcontrast)
}

li {
list-style: none;
}
</style>
2 changes: 1 addition & 1 deletion src/modules/navigation/partials/NavigationContextItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{{ t('tables', 'Delete application') }}
</NcActionButton>
<NcActionCheckbox :checked="showInNavigation" @change="updateDisplayMode">
Show in Navigation
Show in app list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be translatable

</NcActionCheckbox>
</template>
</NcAppNavigationItem>
Expand Down
4 changes: 2 additions & 2 deletions src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,11 @@ export default new Vuex.Store({
commit('setLoading', { key: 'contexts', value: false })
return res.data.ocs.data
},
async updateContext({ state, commit, dispatch }, { id, data, previousReceivers, receivers }) {
async updateContext({ state, commit, dispatch }, { id, data, previousReceivers, receivers, displayMode }) {
let res = null
try {
res = await axios.put(generateOcsUrl('/apps/tables/api/2/contexts/' + id), data)
await dispatch('shareContext', { id, previousReceivers, receivers })
await dispatch('shareContext', { id, previousReceivers, receivers, displayMode })

} catch (e) {
displayError(e, t('tables', 'Could not update application.'))
Expand Down