mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-22 14:47:56 +01:00
Add missing type declaration
This commit is contained in:
parent
d91d6a2472
commit
60fffe2c40
@ -42,16 +42,14 @@ class FeatureModel {
|
|||||||
this[`is${FeatureModel.capitalize(type)}Model`] = () => true;
|
this[`is${FeatureModel.capitalize(type)}Model`] = () => true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
|
||||||
getAttributes() {
|
getAttributes() {
|
||||||
return { ...this._attributes };
|
return { ...this._attributes };
|
||||||
}
|
}
|
||||||
|
|
||||||
static capitalize(str) {
|
static capitalize(str: string) {
|
||||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
|
||||||
setAttributes(attributes) {
|
setAttributes(attributes) {
|
||||||
Object.keys(attributes).forEach((attr) => {
|
Object.keys(attributes).forEach((attr) => {
|
||||||
const funName = `set${FeatureModel.capitalize(attr)}`;
|
const funName = `set${FeatureModel.capitalize(attr)}`;
|
||||||
@ -60,26 +58,22 @@ class FeatureModel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
setAttribute(key: string, value: any) {
|
||||||
setAttribute(key, value) {
|
|
||||||
$assert(key, 'key id can not be null');
|
$assert(key, 'key id can not be null');
|
||||||
this._attributes[key] = value;
|
this._attributes[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
getAttribute(key: string) {
|
||||||
getAttribute(key) {
|
|
||||||
$assert(key, 'key id can not be null');
|
$assert(key, 'key id can not be null');
|
||||||
|
|
||||||
return this._attributes[key];
|
return this._attributes[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
getId(): number {
|
||||||
getId() {
|
|
||||||
return this._id;
|
return this._id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
setId(id: number) {
|
||||||
setId(id) {
|
|
||||||
$assert(Number.isFinite(id));
|
$assert(Number.isFinite(id));
|
||||||
this._id = id;
|
this._id = id;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ class NodeModel extends INodeModel {
|
|||||||
this._features.push(feature);
|
this._features.push(feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
getFeatures() {
|
getFeatures(): FeatureModel[] {
|
||||||
return this._features;
|
return this._features;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ class NodeModel extends INodeModel {
|
|||||||
* @throws will throw an error if feature is null or undefined
|
* @throws will throw an error if feature is null or undefined
|
||||||
* @throws will throw an error if the feature could not be removed
|
* @throws will throw an error if the feature could not be removed
|
||||||
*/
|
*/
|
||||||
removeFeature(feature: FeatureModel) {
|
removeFeature(feature: FeatureModel): void {
|
||||||
$assert(feature, 'feature can not be null');
|
$assert(feature, 'feature can not be null');
|
||||||
const size = this._features.length;
|
const size = this._features.length;
|
||||||
this._features = this._features.filter((f) => feature.getId() !== f.getId());
|
this._features = this._features.filter((f) => feature.getId() !== f.getId());
|
||||||
@ -79,7 +79,7 @@ class NodeModel extends INodeModel {
|
|||||||
* @param {String} type the feature type, e.g. icon or link
|
* @param {String} type the feature type, e.g. icon or link
|
||||||
* @throws will throw an error if type is null or undefined
|
* @throws will throw an error if type is null or undefined
|
||||||
*/
|
*/
|
||||||
findFeatureByType(type: string) {
|
findFeatureByType(type: string): FeatureModel[] {
|
||||||
$assert(type, 'type can not be null');
|
$assert(type, 'type can not be null');
|
||||||
return this._features.filter((feature) => feature.getType() === type);
|
return this._features.filter((feature) => feature.getType() === type);
|
||||||
}
|
}
|
||||||
@ -90,14 +90,13 @@ class NodeModel extends INodeModel {
|
|||||||
* @throws will throw an error if feature could not be found
|
* @throws will throw an error if feature could not be found
|
||||||
* @return the feature with the given id
|
* @return the feature with the given id
|
||||||
*/
|
*/
|
||||||
findFeatureById(id: number) {
|
findFeatureById(id: number): FeatureModel {
|
||||||
$assert($defined(id), 'id can not be null');
|
$assert($defined(id), 'id can not be null');
|
||||||
const result = this._features.filter((feature) => feature.getId() === id);
|
const result = this._features.filter((feature) => feature.getId() === id);
|
||||||
$assert(result.length === 1, `Feature could not be found:${id}`);
|
$assert(result.length === 1, `Feature could not be found:${id}`);
|
||||||
return result[0];
|
return result[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
|
||||||
getPropertiesKeys() {
|
getPropertiesKeys() {
|
||||||
return Object.keys(this._properties);
|
return Object.keys(this._properties);
|
||||||
}
|
}
|
||||||
@ -112,12 +111,10 @@ class NodeModel extends INodeModel {
|
|||||||
this._properties[key] = value;
|
this._properties[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
|
||||||
getProperties() {
|
getProperties() {
|
||||||
return this._properties;
|
return this._properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
|
||||||
getProperty(key: string) {
|
getProperty(key: string) {
|
||||||
$defined(key, 'key can not be null');
|
$defined(key, 'key can not be null');
|
||||||
const result = this._properties[key];
|
const result = this._properties[key];
|
||||||
@ -127,7 +124,7 @@ class NodeModel extends INodeModel {
|
|||||||
/**
|
/**
|
||||||
* @return {mindplot.model.NodeModel} an identical clone of the NodeModel
|
* @return {mindplot.model.NodeModel} an identical clone of the NodeModel
|
||||||
*/
|
*/
|
||||||
clone() {
|
clone(): NodeModel {
|
||||||
const result = new NodeModel(this.getType(), this._mindmap, -1);
|
const result = new NodeModel(this.getType(), this._mindmap, -1);
|
||||||
result._children = this._children.map((node) => {
|
result._children = this._children.map((node) => {
|
||||||
const cnode = node.clone() as NodeModel;
|
const cnode = node.clone() as NodeModel;
|
||||||
|
Loading…
Reference in New Issue
Block a user