@omnia/fx-models
Version:
Provide Omnia Fx Models Stuffs.
151 lines (150 loc) • 8.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
//PropertyInstance
//Simulate api-hub register PropertyDefinition
function registerPropertyDefinition(propertyDefinitionConstructor, readRenderComponentManifestId, editRendererComponentManifestId) {
const propDefinitionId = new propertyDefinitionConstructor().id;
//add manifest ids and propertydef id and typename to extension manifest description
}
class LimitedTextDisplaySettings {
constructor() {
this.dispSetting1 = "";
this.dispSetting2 = "";
}
}
class LimitedTextSettings {
constructor() {
this.setting1 = "";
this.setting2 = "";
}
}
// class LimitedTextPropertyDefinition extends PropertyDefinition<string, LimitedTextDisplaySettings, LimitedTextSettings>{
// id = "LimitedTextPropertyGuid";
// typeName = "LimitedTextProperty";
// }
// let test3: PropertyValueType<LimitedTextPropertyDefinition>;
// //let test5: IPropertyRenderer<LimitedTextPropertyDefinition> = { }
// //Manifest should have WC matching the IPropertyRenderer<LimitedTextPropertyDefinition>
// registerPropertyDefinition<LimitedTextPropertyDefinition>(LimitedTextPropertyDefinition,"manifestid","editmanifestId");
// //Admin create bindingId
// //Simulate getbindings
// function getPropertyDefinitionBindings<TPropertyDef extends PropertyDefinition<any,any,any>>(propertyDefinitionConstructor: new () => TPropertyDef):Array<PropertyBinding<TPropertyDef>>{
// //prop def to get for
// let propDefinition = new propertyDefinitionConstructor();
// //get all {bindingid, bindingtitle,propertydefid }from server
// let bindingIdFromServer = "";
// let bindingTypeNameFromServer = "";
// let propdefidFromServer = "";
// let result: Array<PropertyBinding<TPropertyDef>> = [];
// //loop and
// if(propdefidFromServer === propDefinition.id){
// result.push(new PropertyBinding<TPropertyDef>(propdefidFromServer,bindingTypeNameFromServer,propertyDefinitionConstructor));
// }
// return result
// }
// function getAllPropertyDefinitionBindings():Array<PropertyBinding<PropertyDefinition<any,any,any>>>{
// //get all {bindingid, bindingtitle,propertydefid }from server
// let bindingIdFromServer = "";
// let bindingTypeNameFromServer = "";
// let propdefidFromServer = "";
// let result: Array<PropertyBinding<PropertyDefinition<any,any,any>>> = [];
// //loop and
// result.push(new PropertyBinding<PropertyDefinition<any, any, any>>(bindingIdFromServer, bindingTypeNameFromServer, propdefidFromServer));
// return result
// }
// //Get in typed way from e.g. a store in omnia with bindings
// let limitedTextpropertyDefBindings = getPropertyDefinitionBindings(LimitedTextPropertyDefinition);
// let propertyConfiguration = new PropertyConfiguration("configid",
// "overrridenTypeName",
// limitedTextpropertyDefBindings[0],
// { dispSetting1: "", dispSetting2: "" },
// { setting1: "", setting2: "" });
// //Mapp a binding to a new configuration from a list of all/any binding
// let allbindings = getAllPropertyDefinitionBindings();
// function getManifestForPropertyDef<TPropertyDef extends PropertyDefinition<any, any, any>>(propertyDefinitionConstructor: new () => TPropertyDef): { editManifestId: string, readManifestId: string }
// function getManifestForPropertyDef(propertyDefinitionId: GuidValue): { editManifestId: string, readManifestId: string }
// function getManifestForPropertyDef<TPropertyDef extends PropertyDefinition<any, any, any>>(anyIdProvider: string | { new() : TPropertyDef }): { editManifestId: string, readManifestId: string } {
// let id: GuidValue =null;
// if (typeof anyIdProvider === "string") {
// id = anyIdProvider;
// } else {
// let ctor: new () => TPropertyDef = anyIdProvider;
// id = new ctor().id;
// }
// //new propertyDefinitionConstructor().id;
// return { editManifestId : "manifestid", readManifestId : "manifestId" };
// }
// ///This interface would have some interface related to get the two settings, like ? IP
// let manifestId = getManifestForPropertyDef(allbindings[0].propertyDefinitionId);
// //Use an interface to get the displaysettings and settings, we maybe need some manifest/interface for just creating these seetings?
// //Here we work on any definition type, all should have same contract and we do not care about the exact type here
// let wcInterface: IPropertyValueRenderer<PropertyDefinition<any, any, any>>;
// //get in some way new settings
// let theCreatedDisplaySettings = wcInterface.displaySettings;
// let theCreatedSettings = wcInterface.settings;
// let newCfg = new PropertyConfiguration<PropertyDefinition<any, any, any>>("new guid or internal in ctor?",
// "MyOverriddenNameOtEmpty",
// allbindings[0],
// theCreatedDisplaySettings,
// theCreatedSettings);
// //Call server in e.g. wcm to store the newCfg in a pagetype
// //From wcm possible to get all configurations or getallWcmconfigurationsbyPropertyDef
// //Create a propertyvalue in a wcm page:
// let cfgs: Array<PropertyConfiguration<LimitedTextPropertyDefinition>> = []; //getallWcmconfigurationsbyPropertyDef(LimitedTextPropertyDefinition)
// let newPagePropertyValue: PropertyValue<LimitedTextPropertyDefinition> = new PropertyValue(cfgs[0], "the string value for this property on this page");
// class FakeAppPropertiesProvider extends PropertiesProvider {
// private titleCfg = new PropertyConfiguration("this cfg guid", "", new PropertyBinding("fakebindingId", "Title", LimitedTextPropertyDefinition),
// {
// dispSetting1: "some dummy/default",
// dispSetting2: "some other dummy, to override in the add ui"
// },
// {
// setting1: "500 limt for title in app instance",
// setting2: "something else"
// });
// private descCfg = new PropertyConfiguration("this cfg guid", "", new PropertyBinding("fakebindingId2", "Desc", LimitedTextPropertyDefinition),
// {
// dispSetting1: "some dummy/default",
// dispSetting2: "some other dummy, to override in the add ui"
// },
// {
// setting1: "500 limt for title in app instance",
// setting2: "something else"
// });
// public getPropertyConfigurations = (): Array<PropertyConfiguration<PropertyDefinition<any, any, any>>> => {
// return [this.titleCfg,
// this.descCfg];
// }
// public getPropertyValue = (cfg: PropertyConfiguration<PropertyDefinition<any, any, any>>) => {
// let result: PropertyValue<PropertyDefinition<any, any, any>> = null;
// if (cfg.configurationId === this.titleCfg.configurationId) {
// //get from appinstance or othe rprovider storage
// result = new PropertyValue(this.titleCfg, "appinstance.Title");
// }
// else if (cfg.configurationId === this.descCfg.configurationId) {
// result = new PropertyValue(this.descCfg, "appinstance.desc");
// }
// return result;
// }
// public setPropertyValue = (propertyValue: PropertyValue<PropertyDefinition<any, any, any>>): PropertyValue<PropertyDefinition<any, any, any>> => {
// if (propertyValue.propertyConfigurationId === this.titleCfg.configurationId) {
// //app.instane.title = propertyValue.value
// }
// else if (propertyValue.propertyConfigurationId === this.descCfg.configurationId) {
// //app.instane.desc = propertyValue.value
// }
// //save appinstance settings
// return propertyValue;
// }
// }
// //Fake render properties
// let matchingProvider: PropertiesProvider; //= PropertiesComponent.getProviderInstance(PropertiesComponent.firstProp);
// let matchingCfg = matchingProvider.getPropertyConfigurations().find(x => x.configurationId === "PropertiesComponent.firstProp.cfgId");
// let providerPropValue = matchingProvider.getPropertyValue(matchingCfg);
// //Here we might need to think abit because biding is fake, does not exist as real binding
// let propertyBindingService: any = null;
// let propReadRenderManifestProperties: IPropertyValueRenderer<PropertyDefinition<any,any,any>> = propertyBindingService.GetManifest(matchingCfg);
// propReadRenderManifestProperties.displaySettings = "PropertiesComponent.firstProp.appliedDispSettings";
// propReadRenderManifestProperties.settings = matchingCfg.propertySettings;
// propReadRenderManifestProperties.value = providerPropValue;
////render manifest with the applied propReadRenderManifestProperties