Merged PR 154398: [Embedded] Support Zoom Programmatically

Added zoomLevel as an attribute of ISettings.

Related Work Item: #527743
Related PRs:
-  JS SDK : https://powerbi.visualstudio.com/Embedded/_git/powerbi-javascript/pullrequest/154397
- PBIClients :  https://powerbi.visualstudio.com/PowerBIClients/_git/PowerBIClients/pullrequest/154396

Related work items: #527743
This commit is contained in:
Saleh Mahameed 2021-06-23 18:59:24 +00:00
Родитель af656a8a48
Коммит d5a972ca37
3 изменённых файлов: 34 добавлений и 1 удалений

Просмотреть файл

@ -1087,6 +1087,7 @@ export interface ISettings {
visualRenderedEvents?: boolean;
visualSettings?: IVisualSettings;
localeSettings?: ILocaleSettings;
zoomLevel?: number;
}
export interface IReportBars {
@ -1769,3 +1770,8 @@ export function validateCustomTheme(input: any): IError[] {
const errors: any[] = Validators.customThemeValidator.validate(input);
return errors ? errors.map(normalizeError) : undefined;
}
export function validateZoomLevel(input: any): IError[] {
const errors: any[] = Validators.zoomLevelValidator.validate(input);
return errors ? errors.map(normalizeError) : undefined;
}

Просмотреть файл

@ -189,3 +189,29 @@ export class NumberArrayValidator extends ArrayValidator {
return null;
}
}
export class RangeValidator extends NumberValidator {
constructor(private minValue: number, private maxValue: number) {
super();
}
public validate(input: any, path?: string, field?: string): IValidationError[] {
if (input == null) {
return null;
}
const errors = super.validate(input, path, field);
if (errors) {
return errors;
}
// input is a number, now check if it's in the given range
if(input > this.maxValue || input < this.minValue) {
return [{
message: field + " must be a number between " + this.minValue + " and " + this.maxValue,
path: (path ? path + "." : "") + field,
keyword: "range"
}];
}
return null;
}
}

Просмотреть файл

@ -58,7 +58,7 @@ import { AnyOfValidator } from './anyOfValidator';
import { FieldForbiddenValidator } from './fieldForbiddenValidator';
import { FieldRequiredValidator } from './fieldRequiredValidator';
import { MapValidator } from './mapValidator';
import { ArrayValidator, BooleanArrayValidator, BooleanValidator, EnumValidator, NumberArrayValidator, NumberValidator, StringArrayValidator, StringValidator } from './typeValidator';
import { ArrayValidator, BooleanArrayValidator, BooleanValidator, EnumValidator, NumberArrayValidator, NumberValidator, RangeValidator, StringArrayValidator, StringValidator } from './typeValidator';
import { ParametersPanelValidator } from '../models/parameterPanelValidator';
export interface IValidationError {
@ -198,4 +198,5 @@ export const Validators = {
visualSelectorValidator: new VisualSelectorValidator(),
visualSettingsValidator: new VisualSettingsValidator(),
visualTypeSelectorValidator: new VisualTypeSelectorValidator(),
zoomLevelValidator: new RangeValidator(0.25, 4),
};