mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
all items crossed off
This commit is contained in:
committed by
Aiden McClelland
parent
a61cdb088f
commit
2e6513ed03
@@ -15,7 +15,7 @@
|
|||||||
{{ spec.name }} must be an integer
|
{{ spec.name }} must be an integer
|
||||||
</p>
|
</p>
|
||||||
<p *ngIf="control.hasError('numberNotInRange')">
|
<p *ngIf="control.hasError('numberNotInRange')">
|
||||||
Number not in range
|
{{ control.errors['numberNotInRange'].value }}
|
||||||
</p>
|
</p>
|
||||||
<p *ngIf="control.hasError('notNumber')">
|
<p *ngIf="control.hasError('notNumber')">
|
||||||
{{ spec.name }} must be a number
|
{{ spec.name }} must be a number
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
<!-- list -->
|
<!-- list -->
|
||||||
<ng-container *ngIf="spec.type === 'list'">
|
<ng-container *ngIf="spec.type === 'list'">
|
||||||
<p *ngIf="control.hasError('listNotInRange')">
|
<p *ngIf="control.hasError('listNotInRange')">
|
||||||
List not in range
|
{{ control.errors['listNotInRange'].value }}
|
||||||
</p>
|
</p>
|
||||||
<p *ngIf="control.hasError('listNotUnique')">
|
<p *ngIf="control.hasError('listNotUnique')">
|
||||||
{{ control.errors.listNotUnique.value }}
|
{{ control.errors.listNotUnique.value }}
|
||||||
|
|||||||
@@ -154,7 +154,6 @@ export class FormObjectComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async presentAlertChangeWarning (key: string, spec: ValueSpec, okFn?: Function, cancelFn?: Function) {
|
async presentAlertChangeWarning (key: string, spec: ValueSpec, okFn?: Function, cancelFn?: Function) {
|
||||||
console.log('Here here here', spec['change-warning'])
|
|
||||||
if (!spec['change-warning'] || this.warningAck[key]) return okFn ? okFn() : null
|
if (!spec['change-warning'] || this.warningAck[key]) return okFn ? okFn() : null
|
||||||
this.warningAck[key] = true
|
this.warningAck[key] = true
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { AbstractControl, FormArray, FormBuilder, FormControl, FormGroup, ValidationErrors, ValidatorFn, Validators } from '@angular/forms'
|
import { AbstractControl, FormArray, FormBuilder, FormControl, FormGroup, ValidationErrors, ValidatorFn, Validators } from '@angular/forms'
|
||||||
import { ConfigSpec, isValueSpecListOf, ListValueSpecNumber, ListValueSpecObject, ListValueSpecOf, ListValueSpecString, ListValueSpecUnion, UniqueBy, ValueSpec, ValueSpecEnum, ValueSpecList, ValueSpecListOf, ValueSpecNumber, ValueSpecObject, ValueSpecString, ValueSpecUnion } from '../pkg-config/config-types'
|
import { ConfigSpec, isValueSpecListOf, ListValueSpecNumber, ListValueSpecObject, ListValueSpecString, ListValueSpecUnion, UniqueBy, ValueSpec, ValueSpecEnum, ValueSpecList, ValueSpecListOf, ValueSpecNumber, ValueSpecObject, ValueSpecString, ValueSpecUnion } from '../pkg-config/config-types'
|
||||||
import { getDefaultString, Range } from '../pkg-config/config-utilities'
|
import { getDefaultString, Range } from '../pkg-config/config-utilities'
|
||||||
const Mustache = require('mustache')
|
const Mustache = require('mustache')
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ export function numberInRange (stringRange: string): ValidatorFn {
|
|||||||
Range.from(stringRange).checkIncludes(control.value)
|
Range.from(stringRange).checkIncludes(control.value)
|
||||||
return null
|
return null
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return { numberNotInRange: { value: control.value } }
|
return { numberNotInRange: { value: getRangeMessage(stringRange) } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -186,13 +186,25 @@ export function listInRange (stringRange: string): ValidatorFn {
|
|||||||
const max = range.integralMax()
|
const max = range.integralMax()
|
||||||
const length = control.value.length
|
const length = control.value.length
|
||||||
if ((min && length < min) || (max && length > max)) {
|
if ((min && length < min) || (max && length > max)) {
|
||||||
return { listNotInRange: { value: control.value } }
|
return { listNotInRange: { value: getRangeMessage(stringRange, true) } }
|
||||||
} else {
|
} else {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRangeMessage (stringRange: string, isList = false): string {
|
||||||
|
const range = Range.from(stringRange)
|
||||||
|
const min = range.integralMin()
|
||||||
|
const max = range.integralMax()
|
||||||
|
const messageStart = isList ? 'List length must be ' : 'Must be '
|
||||||
|
const minMessage = !!min ? `greater than ${min}` : ''
|
||||||
|
const and = !!min && !!max ? ' and ' : ''
|
||||||
|
const maxMessage = !!max ? `less than ${max}` : ''
|
||||||
|
|
||||||
|
return `${messageStart} ${minMessage}${and}${maxMessage}`
|
||||||
|
}
|
||||||
|
|
||||||
export function listUnique (spec: ValueSpecList): ValidatorFn {
|
export function listUnique (spec: ValueSpecList): ValidatorFn {
|
||||||
return (control: AbstractControl): ValidationErrors | null => {
|
return (control: AbstractControl): ValidationErrors | null => {
|
||||||
for (let idx = 0; idx < control.value.length; idx++) {
|
for (let idx = 0; idx < control.value.length; idx++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user