Skip to content

Commit

Permalink
bug(Notes): Fix note popouts no longer editable without edit rights
Browse files Browse the repository at this point in the history
  • Loading branch information
Kruptein authored Nov 12, 2024
1 parent e934b4a commit cb47214
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ tech changes will usually be stripped from release notes for the public
- This fixes some of the entries in the Fixed section
- AssetManager:
- Changed UI of renaming assets, allowing inline editing rather than opening a popup
- Notes:
- Note popouts for clients without edit access now show 'view source' instead of 'edit'

### Removed

Expand All @@ -53,6 +55,7 @@ tech changes will usually be stripped from release notes for the public
- Default edit access on notes was not correctly applied
- Fix searchbar overlapping over other modals
- Global notes no longer have a default access level
- Notes can no longer be locally edited by clients without edit access through the note popouts
- Shape Properties:
- Input changes could not persist or save on the wrong shape if selection focus was changed while editing (see selection changes)
- Modals
Expand Down
20 changes: 17 additions & 3 deletions client/src/game/ui/notes/NoteDialog.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<script setup lang="ts">
import { nextTick, onMounted, onUnmounted, reactive, ref, type Ref } from "vue";
import { computed, nextTick, onMounted, onUnmounted, reactive, ref, type Ref } from "vue";
import VueMarkdown from "vue-markdown-render";
import Modal from "../../../core/components/modals/Modal.vue";
import { coreStore } from "../../../store/core";
import { modalSystem } from "../../systems/modals";
import type { ModalIndex } from "../../systems/modals/types";
import { noteSystem } from "../../systems/notes";
Expand All @@ -18,6 +19,13 @@ const modal = ref<{ container: Ref<HTMLDivElement> } | null>(null);
const note = noteState.reactive.notes.get(props.uuid);
const canEdit = computed(() => {
if (!note) return false;
const username = coreStore.state.username;
if (note.creator === username) return true;
return note.access.some((a) => (a.name === username || a.name === "default") && a.can_edit);
});
onMounted(() => {
if (modal.value) {
constrainInitialLoadDimensions();
Expand Down Expand Up @@ -158,7 +166,7 @@ function windowToggle(windowed: boolean): void {
<font-awesome-icon :icon="['far', 'window-close']" title="Close note" @click="close" />
</div>
<div>
<div v-if="!editing" @click="editing = true">[edit]</div>
<div v-if="!editing" @click="editing = true">[{{ canEdit ? "edit" : "view source" }}]</div>
<div v-else @click="editing = false">[show]</div>
<div @click.stop="editNote(uuid)">[open in note manager]</div>
</div>
Expand All @@ -167,7 +175,13 @@ function windowToggle(windowed: boolean): void {

<div v-if="!collapsed.active" class="note-body">
<VueMarkdown v-if="!editing" :source="note.text" :options="{ html: true }" />
<textarea v-else v-model="note.text" @input="setText($event, false)" @change="setText($event, true)" />
<textarea
v-else
v-model="note.text"
:readonly="!canEdit"
@input="setText($event, false)"
@change="setText($event, true)"
/>
</div>
</Modal>
</template>
Expand Down

0 comments on commit cb47214

Please sign in to comment.