Skip to content
Merged
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
23 changes: 17 additions & 6 deletions src/commands/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export async function deleteProject(node: ProjectNode | undefined): Promise<any>

/**
* @param Name The name of the item to add.
* @param Type The type of the item to add. Either "MAC", "CLS", "PKG", "CSP", "DIR" or "OTH".
* @param Type The type of the item to add. Either "MAC", "CLS", "PKG", "CSP", "DIR", or an abstract document type like "OTH" or "LUT".
* @param items The items currently in the project.
*/
function addProjectItem(
Expand Down Expand Up @@ -268,7 +268,7 @@ function addProjectItem(
(item.Type == "CSP" || item.Type == "DIR") && item.Name.toLowerCase().startsWith(`${Name.toLowerCase()}/`)
)
);
} else if (Type == "OTH" && !items.some((item) => item.Name.toLowerCase() == Name.toLowerCase())) {
} else if (!items.some((item) => item.Name.toLowerCase() == Name.toLowerCase())) {
add.push({ Name, Type });
}

Expand Down Expand Up @@ -321,8 +321,15 @@ export function removeProjectItem(Name: string, Type: string, items: ProjectItem
)
);
}
} else if (Type == "OTH" && items.some((item) => item.Name.toLowerCase() == Name.toLowerCase())) {
remove.push({ Name, Type: items.find((item) => item.Name.toLowerCase() == Name.toLowerCase())?.Type ?? Type });
} else if (Type == "OTH") {
// Remove all items of any abstract document type that have the same name as the target item
remove.concat(
items.filter(
(item) =>
item.Name.toLowerCase() == Name.toLowerCase() &&
!["MAC", "CLS", "PKG", "CSP", "DIR", "GBL"].includes(item.Type)
)
);
}

return remove;
Expand Down Expand Up @@ -680,7 +687,9 @@ export async function modifyProject(
type = "DIR";
}
} else {
type = "OTH";
// Other tools like Production deployment expect the Type of
// an abstract document item to be the document's extension
type = ext.toUpperCase();
}

let newAdd: ProjectItem[] = [];
Expand Down Expand Up @@ -952,7 +961,9 @@ export async function addIsfsFileToProject(project: string, fileName: string, ap
? "CLS"
: ["mac", "int", "inc"].includes(ext)
? "MAC"
: "OTH";
: // Other tools like Production deployment expect the Type of
// an abstract document item to be the document's extension
ext.toUpperCase();
const items: ProjectItem[] = await api
.actionQuery("SELECT Name, Type FROM %Studio.Project_ProjectItemsList(?,?) WHERE Type != 'GBL'", [project, "1"])
.then((data) => data.result.content);
Expand Down