Skip to content

Commit

Permalink
0.1.1 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Kaminski committed Mar 6, 2016
1 parent fc1528c commit 210f592
Show file tree
Hide file tree
Showing 15 changed files with 209 additions and 111 deletions.
14 changes: 10 additions & 4 deletions build/tasks/prepare-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,24 @@ gulp.task('changelog', function(callback) {
return changelog({
repository: pkg.repository.url,
version: pkg.version,
file: paths.doc + '/CHANGELOG.md'
file: paths.doc + '/CHANGELOG.md',
preset: 'angular'
}, function(err, log) {
fs.writeFileSync(paths.doc + '/CHANGELOG.md', log);
});
});

gulp.task('copy-build-to-dist', function() {
return gulp.src(paths.output + '**/*')
.pipe(gulp.dest(paths.release.output));
});

gulp.task('prepare-release', function(callback){
return runSequence(
'lint',
'bump-version',
'doc',
'changelog',
//'doc',
//'changelog',
'export',
callback
);
});
1 change: 1 addition & 0 deletions dist/amd/grid/column.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ System.register(['aurelia-templating', 'aurelia-dependency-injection', 'marvelou
_this.grid.internals.dragAndDropListeners.forEach(function (l) { return l.canceled(e, el, _this.column); });
},
started: function (e, el) {
_this.grid.internals.createTempContainer();
_this.grid.internals.dragAndDropListeners.forEach(function (l) { return l.started(e, el, _this.column); });
}
}
Expand Down
17 changes: 9 additions & 8 deletions dist/amd/grid/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ System.register(['aurelia-templating', 'aurelia-dependency-injection', 'marvelou
function Grid(element, components, aureliaUtils, renderer, domSettingsReader, optionsReaderFactory, container) {
this.initialized = false;
this.subs = [];
this._stateContainerName = '__m-grid__';
this._domOptionsElement = element.cloneNode(true);
this.components = components;
this.aureliaUtils = aureliaUtils;
Expand Down Expand Up @@ -110,12 +111,12 @@ System.register(['aurelia-templating', 'aurelia-dependency-injection', 'marvelou
*/
Grid.prototype.loadState = function (serializedState) {
var state = JSON.parse(serializedState);
this.components.forEachInstanceWithMethod('loadState', function (instance) {
var name = instance.constructor.name;
instance.loadState(state[name] || {});
this.components.forEachInstanceWithMethod('loadState', function (x) {
var name = x.component.name;
x.instance.loadState(state[name] || {});
});
// beside components main grid has state as well
this._loadMainGridState(state[Grid.name] || {});
this._loadMainGridState(state[this._stateContainerName] || {});
this.internals.refresh();
};
/**
Expand All @@ -124,13 +125,13 @@ System.register(['aurelia-templating', 'aurelia-dependency-injection', 'marvelou
*/
Grid.prototype.saveState = function () {
var state = {};
this.components.forEachInstanceWithMethod('saveState', function (instance) {
var name = instance.constructor.name; // TODO: won't work with IE9
this.components.forEachInstanceWithMethod('saveState', function (x) {
var name = x.component.name;
state[name] = state[name] || {};
instance.saveState(state[name]);
x.instance.saveState(state[name]);
});
// main grid has state as well
var name = Grid.name;
var name = this._stateContainerName;
state[name] = state[name] || {};
this._saveMainGridState(state[name]);
return JSON.stringify(state);
Expand Down
40 changes: 29 additions & 11 deletions dist/amd/grid/pluginability.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,30 +94,39 @@ System.register(['aurelia-dependency-injection', 'marvelous-aurelia-core/utils',
layout: constants_1.componentLayout.full
}), false);
this.add(new ComponentRegistration({
name: 'm-sorting',
type: all_1.SortingComponent,
position: constants_1.componentPosition.background
}), false);
this.add(new ComponentRegistration({
name: 'm-column-chooser',
type: all_1.ColumnChooserComponent,
view: './components/column-chooser.html',
position: constants_1.componentPosition.background
}), false);
this.add(new ComponentRegistration({
name: 'm-column-reordedring',
type: all_1.ColumnReorderingComponent,
position: constants_1.componentPosition.background
}), false);
this.forEach(function (x) { return x.load(); });
this.forEach(function (x) { return x._load(); });
};
ComponentsArray.prototype.add = function (component, autoLoad) {
var _this = this;
if (autoLoad === void 0) { autoLoad = true; }
if (!(component instanceof ComponentRegistration)) {
throw new Error('Given component has to be an instance of Component type.');
}
component.init(this.grid, this.container, function () { _this.refreshComponentsToBeDisplayed(); });
this._checkNameUniqueness(component.name);
component._init(this.grid, this.container, function () { _this.refreshComponentsToBeDisplayed(); });
this.push(component);
if (autoLoad) {
component.load();
component._load();
}
};
ComponentsArray.prototype._checkNameUniqueness = function (name) {
if (this.filter(function (x) { return x.name == name; }).length > 0) {
throw new Error("Component named as '" + name + "' is already defined.");
}
};
ComponentsArray.prototype.get = function (type) {
Expand All @@ -131,11 +140,17 @@ System.register(['aurelia-dependency-injection', 'marvelous-aurelia-core/utils',
var instances = [];
this.forEach(function (component) {
if (component.instance) {
instances.push(component.instance);
instances.push({
component: component,
instance: component.instance
});
}
if (component.instances) {
component.instances.forEach(function (x) {
instances.push(x);
instances.push({
component: component,
instance: x
});
});
}
});
Expand All @@ -145,9 +160,9 @@ System.register(['aurelia-dependency-injection', 'marvelous-aurelia-core/utils',
* Invokes action for each instance with defined given method.
*/
ComponentsArray.prototype.forEachInstanceWithMethod = function (method, action) {
this.getAllInstances().forEach(function (instance) {
if (instance && instance[method] instanceof Function) {
action(instance);
this.getAllInstances().forEach(function (x) {
if (x.instance && x.instance[method] instanceof Function) {
action(x);
}
});
};
Expand Down Expand Up @@ -181,6 +196,9 @@ System.register(['aurelia-dependency-injection', 'marvelous-aurelia-core/utils',
this.enabled = false;
this._onEnabledChanged = utils_1.Utils.noop;
this._loaded = false;
if (!component.name) {
throw new Error("Component needs to declare its own name.");
}
var missingField = false;
if (component.position == constants_1.componentPosition.background) {
if (utils_1.Utils.allDefined(component, 'type') === false) {
Expand All @@ -203,12 +221,12 @@ System.register(['aurelia-dependency-injection', 'marvelous-aurelia-core/utils',
this.layout = this.layout || constants_1.componentLayout.full;
}
}
ComponentRegistration.prototype.init = function (grid, container, onEnabledChanged) {
ComponentRegistration.prototype._init = function (grid, container, onEnabledChanged) {
this._onEnabledChanged = onEnabledChanged || this._onEnabledChanged;
this._grid = grid;
this._container = container;
};
ComponentRegistration.prototype.load = function () {
ComponentRegistration.prototype._load = function () {
var _this = this;
if (this._loaded) {
return;
Expand Down Expand Up @@ -287,7 +305,7 @@ System.register(['aurelia-dependency-injection', 'marvelous-aurelia-core/utils',
if (this._loaded) {
return;
}
this.load();
this._load();
};
/**
* Creates view models. Depending on the layout it may create a single view model
Expand Down
32 changes: 20 additions & 12 deletions dist/amd/marvelous-aurelia-grid.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,29 @@ declare module "marvelous-aurelia-grid/grid/pluginability" {
import { Container } from 'aurelia-dependency-injection';
import { Column } from 'marvelous-aurelia-grid/grid/all';
import { Grid } from 'marvelous-aurelia-grid/grid/grid';
export class ComponentsArray extends Array<ComponentRegistration> {
export class ComponentsArray extends Array<ComponentRegistration<any>> {
container: any;
grid: Grid;
componentsToBeDisplayed: {};
constructor(container: any);
init(grid: Grid): void;
add(component: ComponentRegistration, autoLoad?: boolean): void;
get(type: Function): ComponentRegistration;
getAllInstances(): Array<any>;
add(component: ComponentRegistration<any>, autoLoad?: boolean): void;
private _checkNameUniqueness(name);
get<T extends GridComponent>(type: {
new (...args): T;
}): ComponentRegistration<T>;
getAllInstances(): IComponentInstance<any>[];
/**
* Invokes action for each instance with defined given method.
*/
forEachInstanceWithMethod(method: string, action: (instance: any) => void): void;
forEachInstanceWithMethod(method: string, action: (instance: IComponentInstance<any>) => void): void;
refreshComponentsToBeDisplayed(): void;
}
export interface IComponentRegistrationDefinition {
/**
* Name of the component.
*/
name?: string;
name: string;
/**
* Component's constructor function.
*/
Expand All @@ -113,12 +116,12 @@ declare module "marvelous-aurelia-grid/grid/pluginability" {
*/
layout?: string;
}
export class ComponentRegistration {
export class ComponentRegistration<T extends GridComponent> {
type: Function;
position: any;
view: any;
instance: any;
instances: Map<Column, any>;
instance: T;
instances: Map<Column, T>;
layout: any;
name: string;
enabled: boolean;
Expand All @@ -127,8 +130,8 @@ declare module "marvelous-aurelia-grid/grid/pluginability" {
private _container;
private _loaded;
constructor(component: IComponentRegistrationDefinition);
init(grid: Grid, container: Container, onEnabledChanged: Function): void;
load(): void;
_init(grid: Grid, container: Container, onEnabledChanged: Function): void;
_load(): void;
/**
* Enables the component.
*/
Expand All @@ -140,7 +143,7 @@ declare module "marvelous-aurelia-grid/grid/pluginability" {
/**
* Gets all instances associated with current component.
*/
getAllInstances(): any[];
getAllInstances(): GridComponent[];
private _ensureLoaded();
/**
* Creates view models. Depending on the layout it may create a single view model
Expand Down Expand Up @@ -184,6 +187,10 @@ declare module "marvelous-aurelia-grid/grid/pluginability" {
*/
loadState(state: any): void;
}
export interface IComponentInstance<T extends GridComponent> {
component: ComponentRegistration<T>;
instance: GridComponent;
}
}
declare module "marvelous-aurelia-grid/grid/gridRenderer" {
import { IDataRow, Grid, Column } from 'marvelous-aurelia-grid/grid/all';
Expand Down Expand Up @@ -382,6 +389,7 @@ declare module "marvelous-aurelia-grid/grid/grid" {
internals: GridInternals;
subs: (() => void)[];
private _domOptionsElement;
private _stateContainerName;
constructor(element: HTMLElement, components: ComponentsArray, aureliaUtils: AureliaUtils, renderer: GridRenderer, domSettingsReader: DOMSettingsReader, optionsReaderFactory: OptionsReaderFactory, container: Container);
bind(executionContext: any): void;
attached(): void;
Expand Down
1 change: 1 addition & 0 deletions dist/common/grid/column.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ System.register(['aurelia-templating', 'aurelia-dependency-injection', 'marvelou
_this.grid.internals.dragAndDropListeners.forEach(function (l) { return l.canceled(e, el, _this.column); });
},
started: function (e, el) {
_this.grid.internals.createTempContainer();
_this.grid.internals.dragAndDropListeners.forEach(function (l) { return l.started(e, el, _this.column); });
}
}
Expand Down
17 changes: 9 additions & 8 deletions dist/common/grid/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ System.register(['aurelia-templating', 'aurelia-dependency-injection', 'marvelou
function Grid(element, components, aureliaUtils, renderer, domSettingsReader, optionsReaderFactory, container) {
this.initialized = false;
this.subs = [];
this._stateContainerName = '__m-grid__';
this._domOptionsElement = element.cloneNode(true);
this.components = components;
this.aureliaUtils = aureliaUtils;
Expand Down Expand Up @@ -110,12 +111,12 @@ System.register(['aurelia-templating', 'aurelia-dependency-injection', 'marvelou
*/
Grid.prototype.loadState = function (serializedState) {
var state = JSON.parse(serializedState);
this.components.forEachInstanceWithMethod('loadState', function (instance) {
var name = instance.constructor.name;
instance.loadState(state[name] || {});
this.components.forEachInstanceWithMethod('loadState', function (x) {
var name = x.component.name;
x.instance.loadState(state[name] || {});
});
// beside components main grid has state as well
this._loadMainGridState(state[Grid.name] || {});
this._loadMainGridState(state[this._stateContainerName] || {});
this.internals.refresh();
};
/**
Expand All @@ -124,13 +125,13 @@ System.register(['aurelia-templating', 'aurelia-dependency-injection', 'marvelou
*/
Grid.prototype.saveState = function () {
var state = {};
this.components.forEachInstanceWithMethod('saveState', function (instance) {
var name = instance.constructor.name; // TODO: won't work with IE9
this.components.forEachInstanceWithMethod('saveState', function (x) {
var name = x.component.name;
state[name] = state[name] || {};
instance.saveState(state[name]);
x.instance.saveState(state[name]);
});
// main grid has state as well
var name = Grid.name;
var name = this._stateContainerName;
state[name] = state[name] || {};
this._saveMainGridState(state[name]);
return JSON.stringify(state);
Expand Down
Loading

0 comments on commit 210f592

Please sign in to comment.