Refactor to unify scripts/categories as Executable
This commit consolidates scripts and categories under a unified 'Executable' concept. This simplifies the architecture and improves code readability. - Introduce subfolders within `src/domain` to segregate domain elements. - Update class and interface names by removing the 'I' prefix in alignment with new coding standards. - Replace 'Node' with 'Executable' to clarify usage; reserve 'Node' exclusively for the UI's tree component.
This commit is contained in:
@@ -18,7 +18,7 @@ import {
|
||||
} from 'vue';
|
||||
import { injectKey } from '@/presentation/injectionSymbols';
|
||||
import type { ICodeChangedEvent } from '@/application/Context/State/Code/Event/ICodeChangedEvent';
|
||||
import type { IScript } from '@/domain/IScript';
|
||||
import type { Script } from '@/domain/Executables/Script/Script';
|
||||
import { ScriptingLanguage } from '@/domain/ScriptingLanguage';
|
||||
import type { IReadOnlyCategoryCollectionState } from '@/application/Context/State/ICategoryCollectionState';
|
||||
import { CodeBuilderFactory } from '@/application/Context/State/Code/Generation/CodeBuilderFactory';
|
||||
@@ -108,7 +108,7 @@ export default defineComponent({
|
||||
highlightedRange.value = 0;
|
||||
}
|
||||
|
||||
function reactToChanges(event: ICodeChangedEvent, scripts: ReadonlyArray<IScript>) {
|
||||
function reactToChanges(event: ICodeChangedEvent, scripts: ReadonlyArray<Script>) {
|
||||
const positions = scripts
|
||||
.map((script) => event.getScriptPositionInCode(script));
|
||||
const start = Math.min(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { IScript } from '@/domain/IScript';
|
||||
import { RecommendationLevel } from '@/domain/RecommendationLevel';
|
||||
import type { Script } from '@/domain/Executables/Script/Script';
|
||||
import { RecommendationLevel } from '@/domain/Executables/Script/RecommendationLevel';
|
||||
import { scrambledEqual } from '@/application/Common/Array';
|
||||
import type { ICategoryCollection } from '@/domain/ICategoryCollection';
|
||||
import type { ReadonlyScriptSelection, ScriptSelection } from '@/application/Context/State/Selection/Script/ScriptSelection';
|
||||
@@ -90,7 +90,7 @@ function selectOnly(
|
||||
}
|
||||
|
||||
function areAllSelected(
|
||||
expectedScripts: ReadonlyArray<IScript>,
|
||||
expectedScripts: ReadonlyArray<Script>,
|
||||
selection: ReadonlyArray<SelectedScript>,
|
||||
): boolean {
|
||||
const selectedScriptIds = selection
|
||||
|
||||
@@ -59,8 +59,8 @@ import {
|
||||
} from 'vue';
|
||||
import { injectKey } from '@/presentation/injectionSymbols';
|
||||
import TooltipWrapper from '@/presentation/components/Shared/TooltipWrapper.vue';
|
||||
import { RecommendationLevel } from '@/domain/RecommendationLevel';
|
||||
import type { IScript } from '@/domain/IScript';
|
||||
import { RecommendationLevel } from '@/domain/Executables/Script/RecommendationLevel';
|
||||
import type { Script } from '@/domain/Executables/Script/Script';
|
||||
import MenuOptionList from '../MenuOptionList.vue';
|
||||
import MenuOptionListItem from '../MenuOptionListItem.vue';
|
||||
import RevertStatusDocumentation from './RevertStatusDocumentation.vue';
|
||||
@@ -83,7 +83,7 @@ export default defineComponent({
|
||||
() => getCurrentRevertStatus(currentSelection.value.scripts),
|
||||
);
|
||||
|
||||
const selectedScripts = computed<readonly IScript[]>(
|
||||
const selectedScripts = computed<readonly Script[]>(
|
||||
() => currentSelection.value.scripts.selectedScripts.map((s) => s.script),
|
||||
);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
import { defineComponent, computed } from 'vue';
|
||||
import AppIcon from '@/presentation/components/Shared/Icon/AppIcon.vue';
|
||||
import { injectKey } from '@/presentation/injectionSymbols';
|
||||
import type { ICategory } from '@/domain/ICategory';
|
||||
import type { Category } from '@/domain/Executables/Category/Category';
|
||||
import type { ICategoryCollection } from '@/domain/ICategoryCollection';
|
||||
|
||||
export default defineComponent({
|
||||
@@ -33,7 +33,7 @@ export default defineComponent({
|
||||
const { currentSelection } = injectKey((keys) => keys.useUserSelectionState);
|
||||
const currentCollection = computed<ICategoryCollection>(() => currentState.value.collection);
|
||||
|
||||
const currentCategory = computed<ICategory>(
|
||||
const currentCategory = computed<Category>(
|
||||
() => currentCollection.value.getCategory(props.categoryId),
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { ICategory, IScript } from '@/domain/ICategory';
|
||||
import type { Category } from '@/domain/Executables/Category/Category';
|
||||
import type { ICategoryCollection } from '@/domain/ICategoryCollection';
|
||||
import type { Script } from '@/domain/Executables/Script/Script';
|
||||
import { type NodeMetadata, NodeType } from '../NodeContent/NodeMetadata';
|
||||
|
||||
export function parseAllCategories(collection: ICategoryCollection): NodeMetadata[] {
|
||||
@@ -15,7 +16,7 @@ export function parseSingleCategory(
|
||||
return tree;
|
||||
}
|
||||
|
||||
export function getScriptNodeId(script: IScript): string {
|
||||
export function getScriptNodeId(script: Script): string {
|
||||
return script.id;
|
||||
}
|
||||
|
||||
@@ -27,12 +28,12 @@ export function getCategoryId(nodeId: string): number {
|
||||
return +nodeId;
|
||||
}
|
||||
|
||||
export function getCategoryNodeId(category: ICategory): string {
|
||||
export function getCategoryNodeId(category: Category): string {
|
||||
return `${category.id}`;
|
||||
}
|
||||
|
||||
function parseCategoryRecursively(
|
||||
parentCategory: ICategory,
|
||||
parentCategory: Category,
|
||||
): NodeMetadata[] {
|
||||
return [
|
||||
...createCategoryNodes(parentCategory.subCategories),
|
||||
@@ -40,19 +41,19 @@ function parseCategoryRecursively(
|
||||
];
|
||||
}
|
||||
|
||||
function createScriptNodes(scripts: ReadonlyArray<IScript>): NodeMetadata[] {
|
||||
function createScriptNodes(scripts: ReadonlyArray<Script>): NodeMetadata[] {
|
||||
return (scripts || [])
|
||||
.map((script) => convertScriptToNode(script));
|
||||
}
|
||||
|
||||
function createCategoryNodes(categories: ReadonlyArray<ICategory>): NodeMetadata[] {
|
||||
function createCategoryNodes(categories: ReadonlyArray<Category>): NodeMetadata[] {
|
||||
return (categories || [])
|
||||
.map((category) => ({ category, children: parseCategoryRecursively(category) }))
|
||||
.map((data) => convertCategoryToNode(data.category, data.children));
|
||||
}
|
||||
|
||||
function convertCategoryToNode(
|
||||
category: ICategory,
|
||||
category: Category,
|
||||
children: readonly NodeMetadata[],
|
||||
): NodeMetadata {
|
||||
return {
|
||||
@@ -65,7 +66,7 @@ function convertCategoryToNode(
|
||||
};
|
||||
}
|
||||
|
||||
function convertScriptToNode(script: IScript): NodeMetadata {
|
||||
function convertScriptToNode(script: Script): NodeMetadata {
|
||||
return {
|
||||
id: getScriptNodeId(script),
|
||||
type: NodeType.Script,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {
|
||||
type Ref, shallowReadonly, shallowRef,
|
||||
} from 'vue';
|
||||
import type { IScript } from '@/domain/IScript';
|
||||
import type { ICategory } from '@/domain/ICategory';
|
||||
import type { Script } from '@/domain/Executables/Script/Script';
|
||||
import type { Category } from '@/domain/Executables/Category/Category';
|
||||
import { injectKey } from '@/presentation/injectionSymbols';
|
||||
import type { ReadonlyFilterContext } from '@/application/Context/State/Filter/FilterContext';
|
||||
import type { FilterResult } from '@/application/Context/State/Filter/Result/FilterResult';
|
||||
@@ -76,10 +76,10 @@ function filterMatches(node: NodeMetadata, filter: FilterResult): boolean {
|
||||
|| containsCategory(node, filter.categoryMatches);
|
||||
}
|
||||
|
||||
function containsScript(expected: NodeMetadata, scripts: readonly IScript[]) {
|
||||
return scripts.some((existing: IScript) => expected.id === getScriptNodeId(existing));
|
||||
function containsScript(expected: NodeMetadata, scripts: readonly Script[]) {
|
||||
return scripts.some((existing: Script) => expected.id === getScriptNodeId(existing));
|
||||
}
|
||||
|
||||
function containsCategory(expected: NodeMetadata, categories: readonly ICategory[]) {
|
||||
return categories.some((existing: ICategory) => expected.id === getCategoryNodeId(existing));
|
||||
function containsCategory(expected: NodeMetadata, categories: readonly Category[]) {
|
||||
return categories.some((existing: Category) => expected.id === getCategoryNodeId(existing));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user