Skip to content
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

Remove <LetterCircle> #52

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/actions/build-and-test-branch/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ runs:

- name: Ensure frontend configuration files exist
run: |
python manage.py check --tag=compatibility
python manage.py check
shell: bash

- name: Install Arches applications
Expand Down Expand Up @@ -74,7 +74,7 @@ runs:

- name: Check for missing migrations
run: |
python manage.py makemigrations --check --skip-checks
python manage.py makemigrations --check
shell: bash

- name: Ensure previous Python coverage data is erased
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ import {
selectedLanguageKey,
systemLanguageKey,
} from "@/arches_references/constants.ts";
import LetterCircle from "@/arches_references/components/misc/LetterCircle.vue";

import type { Ref } from "vue";
import type { Language } from "@/arches_vue_utils/types";
import type { ControlledListItem } from "@/arches_references/types";

const selectedLanguage = inject(selectedLanguageKey) as Ref<Language>;
const systemLanguage = inject(systemLanguageKey) as Language;
const item = inject(
itemKey,
) as Ref<ControlledListItem> as Ref<ControlledListItem>;
const item = inject(itemKey) as Ref<ControlledListItem>;

const { $gettext } = useGettext();

Expand All @@ -29,7 +26,10 @@ const iconLabel = (item: ControlledListItem) => {

<template>
<span class="item-header">
<LetterCircle :labelled="item" />
<i
class="pi pi-tag"
:aria-label="$gettext('Item')"
></i>
<h3>
{{
getItemLabel(item, selectedLanguage.code, systemLanguage.code)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ interface FileUploadInternals {
state: FileUploadState;
}

const item = inject(
itemKey,
) as Ref<ControlledListItem> as Ref<ControlledListItem>;
const item = inject(itemKey) as Ref<ControlledListItem>;

const { $gettext } = useGettext();
const toast = useToast();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { inject } from "vue";
import { useGettext } from "vue3-gettext";

import { displayedRowKey } from "@/arches_references/constants.ts";
import LetterCircle from "@/arches_references/components/misc/LetterCircle.vue";
import ListCharacteristic from "@/arches_references/components/editor/ListCharacteristic.vue";
import ReferenceNodeLink from "@/arches_references/components/editor/ReferenceNodeLink.vue";

Expand All @@ -20,10 +19,10 @@ const { $gettext } = useGettext();
<template>
<template v-if="list">
<span class="controlled-list-header">
<LetterCircle
v-if="list"
:labelled="list"
/>
<i
class="pi pi-folder"
:aria-label="$gettext('List')"
></i>
<h3>{{ list.name }}</h3>
</span>
<div>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import type { Language } from "@/arches_vue_utils/types";
import type {
ControlledList,
ControlledListItem,
IconLabels,
RowSetter,
Selectable,
} from "@/arches_references/types";
Expand Down Expand Up @@ -101,6 +102,11 @@ const deleteSelectOptions = [
},
];

const iconLabels: IconLabels = {
list: $gettext("List"),
item: $gettext("Item"),
};

const createList = () => {
const newList: ControlledList = {
id: newListCounter.value.toString(),
Expand All @@ -114,7 +120,7 @@ const createList = () => {
nextNewList.value = newList;
newListCounter.value += 1;

tree.value.push(listAsNode(newList, selectedLanguage.value));
tree.value.push(listAsNode(newList, selectedLanguage.value, iconLabels));

selectedKeys.value = { [newList.id]: true };
setDisplayedRow(newList);
Expand Down Expand Up @@ -231,7 +237,9 @@ const fetchListsAndPopulateTree = async () => {
.then(
({ controlled_lists }: { controlled_lists: ControlledList[] }) => {
tree.value = controlled_lists
.map((list) => listAsNode(list, selectedLanguage.value))
.map((list) =>
listAsNode(list, selectedLanguage.value, iconLabels),
)
.sort(
(a, b) =>
priorSortedListIds.indexOf(a.key) -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from "@/arches_references/constants.ts";
import { routeNames } from "@/arches_references/routes.ts";
import { findNodeInTree, nodeIsList } from "@/arches_references/utils.ts";
import LetterCircle from "@/arches_references/components/misc/LetterCircle.vue";
import ListTreeControls from "@/arches_references/components/tree/ListTreeControls.vue";
import TreeRow from "@/arches_references/components/tree/TreeRow.vue";

Expand All @@ -31,12 +30,17 @@ import type {

const { $gettext } = useGettext();

// Defining these in the parent avoids re-running $gettext in thousands of children.
const moveLabels = Object.freeze({
addChild: $gettext("Add child item"),
moveUp: $gettext("Move item up"),
moveDown: $gettext("Move item down"),
changeParent: $gettext("Change item parent"),
});
const iconLabels = Object.freeze({
list: $gettext("List"),
item: $gettext("Item"),
});

const tree: Ref<TreeNode[]> = ref([]);
const selectedKeys: Ref<TreeSelectionKeys> = ref({});
Expand Down Expand Up @@ -227,14 +231,6 @@ function lazyLabelLookup(node: TreeNode) {
).value;
}
}

// Factored out because of vue-tsc problems inside the pt object
const ptNodeContent = ({ instance }: TreePassThroughMethodOptions) => {
if (instance.$el && instance.node.key === movingItem.value?.key) {
instance.$el.classList.add("is-adjusting-parent");
}
return { style: { height: "4rem" } };
};
</script>

<template>
Expand Down Expand Up @@ -288,7 +284,15 @@ const ptNodeContent = ({ instance }: TreePassThroughMethodOptions) => {
},
},
container: { style: { fontSize: '1.4rem' } },
nodeContent: ptNodeContent,
nodeContent: ({ instance }: TreePassThroughMethodOptions) => {
if (instance.$el && instance.node.key === movingItem?.key) {
instance.$el.classList.add('is-adjusting-parent');
}
return { style: { height: '4rem' } };
},
nodeIcon: ({ instance }: TreePassThroughMethodOptions) => {
return { ariaLabel: instance.node.iconLabel };
},
nodeLabel: {
style: {
textWrap: 'nowrap',
Expand All @@ -304,9 +308,6 @@ const ptNodeContent = ({ instance }: TreePassThroughMethodOptions) => {
@node-collapse="nextFilterChangeNeedsExpandAll = true"
@node-select="updateSelectedAndExpanded"
>
<template #nodeicon="slotProps">
<LetterCircle :labelled="slotProps.node.data" />
</template>
<template #default="slotProps">
<TreeRow
v-model:tree="tree"
Expand All @@ -319,6 +320,7 @@ const ptNodeContent = ({ instance }: TreePassThroughMethodOptions) => {
v-model:new-label-form-value="newLabelFormValue"
v-model:new-list-form-value="newListFormValue"
v-model:filter-value="filterValue"
:icon-labels
:move-labels
:node="slotProps.node"
:is-multi-selecting="isMultiSelecting"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import type { Language } from "@/arches_vue_utils/types";
import type {
ControlledList,
ControlledListItem,
IconLabels,
MoveLabels,
RowSetter,
Selectable,
Expand All @@ -55,7 +56,8 @@ const {
setDisplayedRow: RowSetter;
};

const { moveLabels, node } = defineProps<{
const { iconLabels, moveLabels, node } = defineProps<{
iconLabels: IconLabels;
moveLabels: MoveLabels;
node: TreeNode;
}>();
Expand Down Expand Up @@ -107,6 +109,7 @@ const setMovingItem = (node: TreeNode) => {
itemAsNode(
displayedRow.value as ControlledListItem,
selectedLanguage.value,
iconLabels,
),
],
node.key,
Expand Down Expand Up @@ -138,7 +141,9 @@ const addItem = (parent: TreeNode) => {
nextNewItem.value = newItem;
newLabelCounter.value += 1;

parent.children!.push(itemAsNode(newItem, selectedLanguage.value));
parent.children!.push(
itemAsNode(newItem, selectedLanguage.value, iconLabels),
);

expandedKeys.value = {
...expandedKeys.value,
Expand Down Expand Up @@ -181,7 +186,7 @@ const reorder = async (item: ControlledListItem, up: boolean) => {
);
tree.value = [
...tree.value.slice(0, oldListIndex),
listAsNode(list, selectedLanguage.value),
listAsNode(list, selectedLanguage.value, iconLabels),
...tree.value.slice(oldListIndex + 1),
];
selectedKeys.value = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import type { Language } from "@/arches_vue_utils/types";
import type {
ControlledList,
ControlledListItem,
IconLabels,
MoveLabels,
NewControlledListItem,
NewValue,
Expand Down Expand Up @@ -72,8 +73,9 @@ const newListFormValue = defineModel<string>("newListFormValue", {
});
const filterValue = defineModel<string>("filterValue", { required: true });

const { isMultiSelecting, node, moveLabels } = defineProps<{
const { isMultiSelecting, node, iconLabels, moveLabels } = defineProps<{
isMultiSelecting: boolean;
iconLabels: IconLabels;
moveLabels: MoveLabels;
node: TreeNode;
}>();
Expand Down Expand Up @@ -226,7 +228,7 @@ const acceptNewItemShortcutEntry = async () => {

parent.children = [
...parent.children!.filter((child: TreeNode) => !dataIsNew(child.data)),
itemAsNode(newItem, selectedLanguage.value),
itemAsNode(newItem, selectedLanguage.value, iconLabels),
];
if (nodeIsList(parent)) {
parent.data.items.push(newItem);
Expand Down Expand Up @@ -266,7 +268,7 @@ const acceptNewListShortcutEntry = async () => {
}
tree.value = [
...tree.value.filter((cList) => !dataIsNew(cList.data)),
listAsNode(newList, selectedLanguage.value),
listAsNode(newList, selectedLanguage.value, iconLabels),
];
selectedKeys.value = { [newList.id]: true };
setDisplayedRow(newList);
Expand Down Expand Up @@ -346,6 +348,7 @@ const acceptNewListShortcutEntry = async () => {
v-model:moving-item="movingItem"
v-model:next-new-item="nextNewItem"
:node
:icon-labels
:move-labels
/>
</div>
Expand Down
5 changes: 5 additions & 0 deletions arches_references/src/arches_references/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,8 @@ export interface MoveLabels {
moveDown: string;
changeParent: string;
}

export interface IconLabels {
list: string;
item: string;
}
Loading
Loading