All files / app/codeCharta/ui/customConfigs/customConfigList/customConfigItemGroup customConfig2ApplicableMessage.pipe.ts

100% Statements 14/14
100% Branches 5/5
100% Functions 2/2
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 317x 7x     7x           7x 38x     38x   38x 19x       19x 1x   18x 1x   17x      
import { Pipe, PipeTransform } from "@angular/core"
import { State } from "@ngrx/store"
import { CcState } from "../../../../codeCharta.model"
import { CustomConfigItem } from "../../customConfigs.component"
import { getMissingCustomConfigModeAndMaps } from "./getMissingCustomConfigModeAndMaps"
 
@Pipe({
    name: "customConfig2ApplicableMessage",
    standalone: true
})
export class CustomConfig2ApplicableMessage implements PipeTransform {
    constructor(private state: State<CcState>) {}
 
    transform(customConfig: CustomConfigItem): string {
        const { mapSelectionMode, mapNames } = getMissingCustomConfigModeAndMaps(customConfig, this.state.getValue())
 
        if (mapNames.length > 0 && mapSelectionMode.length > 0) {
            return `This view is partially applicable. To complete your view, please switch to the ${mapSelectionMode} mode and select the following map(s): ${mapNames.join(
                ", "
            )}.`
        }
        if (mapNames.length > 0) {
            return `To fulfill your view, please select the following map(s): ${mapNames.join(", ")}.`
        }
        if (mapSelectionMode.length > 0) {
            return `This view is partially applicable. To complete your view, please switch to the ${mapSelectionMode} mode.`
        }
        return `Apply Custom View`
    }
}