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

implement ICheckable for category element #168603

Merged
merged 1 commit into from Dec 9, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -281,6 +281,8 @@ export class BulkEditPane extends ViewPane {
const [first] = this._tree.getFocus();
if ((first instanceof FileElement || first instanceof TextEditElement) && !first.isDisabled()) {
first.setChecked(!first.isChecked());
} else if (first instanceof CategoryElement) {
first.setChecked(!first.isChecked());
}
}

Expand Down
Expand Up @@ -38,12 +38,32 @@ export interface ICheckable {
setChecked(value: boolean): void;
}

export class CategoryElement {
export class CategoryElement implements ICheckable {

constructor(
readonly parent: BulkFileOperations,
readonly category: BulkCategory
) { }

isChecked(): boolean {
const model = this.parent;
let checked = true;
for (const file of this.category.fileOperations) {
for (const edit of file.originalEdits.values()) {
checked = checked && model.checked.isChecked(edit);
}
}
return checked;
}

setChecked(value: boolean): void {
const model = this.parent;
for (const file of this.category.fileOperations) {
for (const edit of file.originalEdits.values()) {
model.checked.updateChecked(edit, value);
}
}
}
}

export class FileElement implements ICheckable {
Expand Down