|
@@ -1,12 +1,16 @@
|
|
-import { IVariable } from './variable';
|
|
|
|
|
|
+// Copyright (c) Jupyter Development Team.
|
|
|
|
+// Distributed under the terms of the Modified BSD License.
|
|
|
|
+
|
|
import { Signal, ISignal } from '@phosphor/signaling';
|
|
import { Signal, ISignal } from '@phosphor/signaling';
|
|
|
|
|
|
|
|
+import { IVariable } from './variable';
|
|
|
|
+
|
|
export interface IVariablesModel {
|
|
export interface IVariablesModel {
|
|
|
|
+ current: IVariable;
|
|
filter: string;
|
|
filter: string;
|
|
variables: IVariable[];
|
|
variables: IVariable[];
|
|
- changeCurrentVariable: ISignal<Model, IVariable>;
|
|
|
|
- changeVariables: ISignal<Model, IVariable[]>;
|
|
|
|
- variable: IVariable;
|
|
|
|
|
|
+ currentChanged: ISignal<Model, IVariable>;
|
|
|
|
+ variablesChanged: ISignal<Model, IVariable[]>;
|
|
}
|
|
}
|
|
|
|
|
|
export namespace IVariablesModel {
|
|
export namespace IVariablesModel {
|
|
@@ -20,69 +24,66 @@ export class Model implements IVariablesModel {
|
|
this._state = model;
|
|
this._state = model;
|
|
}
|
|
}
|
|
|
|
|
|
- get changeCurrentVariable(): ISignal<this, IVariable> {
|
|
|
|
- return this._changeCurrentVariable;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- get changeVariables(): ISignal<this, IVariable[]> {
|
|
|
|
- return this._changeVariables;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- get variables(): IVariable[] {
|
|
|
|
- if (this._filterState) {
|
|
|
|
- return this._filterVariabiles();
|
|
|
|
- }
|
|
|
|
- return this._state;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- set variables(variables: IVariable[]) {
|
|
|
|
- this._state = variables;
|
|
|
|
|
|
+ get currentChanged(): ISignal<this, IVariable> {
|
|
|
|
+ return this._currentChanged;
|
|
}
|
|
}
|
|
|
|
|
|
- get variable(): IVariable {
|
|
|
|
- return this._currentVariabile;
|
|
|
|
|
|
+ get current(): IVariable {
|
|
|
|
+ return this._current;
|
|
}
|
|
}
|
|
-
|
|
|
|
- set variable(variable: IVariable) {
|
|
|
|
- if (this._currentVariabile === variable) {
|
|
|
|
|
|
+ set current(variable: IVariable) {
|
|
|
|
+ if (this._current === variable) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- this._currentVariabile = variable;
|
|
|
|
- this._changeCurrentVariable.emit(variable);
|
|
|
|
|
|
+ this._current = variable;
|
|
|
|
+ this._currentChanged.emit(variable);
|
|
}
|
|
}
|
|
|
|
|
|
get filter() {
|
|
get filter() {
|
|
return this._filterState;
|
|
return this._filterState;
|
|
}
|
|
}
|
|
-
|
|
|
|
set filter(value) {
|
|
set filter(value) {
|
|
if (this._filterState === value) {
|
|
if (this._filterState === value) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
this._filterState = value;
|
|
this._filterState = value;
|
|
- this._changeVariables.emit(this._filterVariabiles());
|
|
|
|
|
|
+ this._variablesChanged.emit(this._filterVariables());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ get variables(): IVariable[] {
|
|
|
|
+ if (this._filterState) {
|
|
|
|
+ return this._filterVariables();
|
|
|
|
+ }
|
|
|
|
+ return this._state;
|
|
|
|
+ }
|
|
|
|
+ set variables(variables: IVariable[]) {
|
|
|
|
+ this._state = variables;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ get variablesChanged(): ISignal<this, IVariable[]> {
|
|
|
|
+ return this._variablesChanged;
|
|
}
|
|
}
|
|
|
|
|
|
getCurrentVariables(): IVariable[] {
|
|
getCurrentVariables(): IVariable[] {
|
|
return this.variables;
|
|
return this.variables;
|
|
}
|
|
}
|
|
|
|
|
|
- fstFil = function(item_name: string) {
|
|
|
|
|
|
+ fstFil(name: string): boolean {
|
|
return (
|
|
return (
|
|
this._filterState
|
|
this._filterState
|
|
.split('')
|
|
.split('')
|
|
- .filter((ele: string, index: number) => item_name[index] === ele)
|
|
|
|
|
|
+ .filter((ele: string, index: number) => name[index] === ele)
|
|
.join('') === this._filterState
|
|
.join('') === this._filterState
|
|
);
|
|
);
|
|
- };
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- private _filterVariabiles(): IVariable[] {
|
|
|
|
|
|
+ private _filterVariables(): IVariable[] {
|
|
return this._state.filter(ele => this.fstFil(ele.name));
|
|
return this._state.filter(ele => this.fstFil(ele.name));
|
|
}
|
|
}
|
|
|
|
|
|
- private _currentVariabile: IVariable;
|
|
|
|
- private _state: IVariable[];
|
|
|
|
|
|
+ private _current: IVariable;
|
|
|
|
+ private _currentChanged = new Signal<this, IVariable>(this);
|
|
|
|
+ private _variablesChanged = new Signal<this, IVariable[]>(this);
|
|
private _filterState: string = '';
|
|
private _filterState: string = '';
|
|
- private _changeCurrentVariable = new Signal<this, IVariable>(this);
|
|
|
|
- private _changeVariables = new Signal<this, IVariable[]>(this);
|
|
|
|
|
|
+ private _state: IVariable[];
|
|
}
|
|
}
|