Skip to content

Commit

Permalink
Refactored Vidyano base library
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleeckx committed Feb 27, 2017
1 parent 10b397b commit eba5ae6
Show file tree
Hide file tree
Showing 59 changed files with 6,921 additions and 5,523 deletions.
1 change: 1 addition & 0 deletions VidyanoClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
</None>
<None Include="package.json" />
<None Include="packages.config" />
<None Include="src\Libs\Vidyano\tsconfig.json" />
<None Include="tsconfig.json" />
<None Include="tslint.json" />
</ItemGroup>
Expand Down
17 changes: 13 additions & 4 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ module.exports = function(grunt) {
},
},
ts: {
default: {
tsconfig: true,
vidyano: {
cwd: 'src/Libs/Vidyano/',
tsconfig: 'src/Libs/Vidyano/tsconfig.json',
options: {
fast: 'never'
}
},
webcomponents: {
tsconfig: "tsconfig.json",
options: {
fast: 'never'
}
Expand All @@ -35,8 +42,10 @@ module.exports = function(grunt) {
},
files: {
src: [
'src/Libs/Vidyano/*.ts',
'src/WebComponents/**/*.ts'
'src/Libs/Vidyano/**/*.ts',
'src/WebComponents/**/*.ts',
'!src/Libs/Vidyano/_reference.ts',
'!src/Libs/Vidyano/vidyano.d.ts'
]
}
},
Expand Down
9 changes: 7 additions & 2 deletions src/Libs/Typings/Vidyano.Common/vidyano.common.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable:interface-name */
interface String {
asDataUri(): string;
contains(str: string): boolean;
Expand Down Expand Up @@ -67,4 +66,10 @@ interface BigNumber {
declare var BigNumber: {
new (number: number | string): BigNumber;
};
/* tslint:enable:interface-name */

declare namespace Vidyano {
export function noop();
export function extend(target: any, ...sources: any[]);
export function splitWithTail(value: string, separator: string | RegExp, limit?: number): string[]
export function _debounce(func: Function, wait: number, immediate?: boolean): Function;
}
26 changes: 26 additions & 0 deletions src/Libs/Vidyano/Actions/cancel-edit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace Vidyano {
"use strict";

export namespace Actions {
export class CancelEdit extends Action {
constructor(service: Service, definition: ActionDefinition, owner: ServiceObjectWithActions) {
super(service, definition, owner);
this.isVisible = this.parent.isEditing;
this.canExecute = this.parent.stateBehavior.indexOf("StayInEdit") < 0 || this.parent.isDirty;
}

_onParentIsEditingChanged(isEditing: boolean) {
this.isVisible = isEditing;
}

_onParentIsDirtyChanged(isDirty: boolean) {
this.canExecute = this.parent.stateBehavior.indexOf("StayInEdit") < 0 || isDirty;
}

protected _onExecute({ menuOption, parameters, selectedItems, skipOpen, noConfirmation, throwExceptions }: IActionExecuteOptions): Promise<PersistentObject> {
this.parent.cancelEdit();
return Promise.resolve(null);
}
}
}
}
16 changes: 16 additions & 0 deletions src/Libs/Vidyano/Actions/cancel-save.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Vidyano {
"use strict";

export namespace Actions {
export class CancelSave extends Action {
constructor(service: Service, definition: ActionDefinition, owner: ServiceObjectWithActions) {
super(service, definition, owner);
}

protected _onExecute({ menuOption, parameters, selectedItems, skipOpen, noConfirmation, throwExceptions }: IActionExecuteOptions): Promise<PersistentObject> {
this.service.hooks.onClose(this.parent);
return Promise.resolve(null);
}
}
}
}
23 changes: 23 additions & 0 deletions src/Libs/Vidyano/Actions/edit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace Vidyano {
"use strict";

export namespace Actions {
export class Edit extends Action {
constructor(service: Service, definition: ActionDefinition, owner: ServiceObjectWithActions) {
super(service, definition, owner);
this.isVisible = !this.parent.isEditing;

this.dependentActions = ["EndEdit", "CancelEdit"];
}

_onParentIsEditingChanged(isEditing: boolean) {
this.isVisible = !isEditing;
}

protected _onExecute({ menuOption, parameters, selectedItems, skipOpen, noConfirmation, throwExceptions }: IActionExecuteOptions): Promise<PersistentObject> {
this.parent.beginEdit();
return Promise.resolve(null);
}
}
}
}
39 changes: 39 additions & 0 deletions src/Libs/Vidyano/Actions/end-edit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace Vidyano {
"use strict";

export namespace Actions {
export class EndEdit extends Action {
constructor(service: Service, definition: ActionDefinition, owner: ServiceObjectWithActions) {
super(service, definition, owner);
this.isVisible = this.parent.isEditing;
this.canExecute = this.parent.isDirty;
}

_onParentIsEditingChanged(isEditing: boolean) {
this.isVisible = isEditing;
}

_onParentIsDirtyChanged(isDirty: boolean) {
this.canExecute = isDirty;
}

protected async _onExecute({ menuOption, parameters, selectedItems, skipOpen, noConfirmation, throwExceptions }: IActionExecuteOptions): Promise<PersistentObject> {
await this.parent.save();
if (StringEx.isNullOrWhiteSpace(this.parent.notification) || this.parent.notificationType !== NotificationType.Error) {
const edit = this.parent.actions["Edit"];
const endEdit = this.parent.actions["EndEdit"];

if (this.parent.stateBehavior.indexOf("StayInEdit") !== -1 && endEdit != null) {
endEdit.canExecute = false;
} else if (edit) {
edit.isVisible = true;
if (endEdit != null)
endEdit.isVisible = false;
}
}

return this.parent;
}
}
}
}
16 changes: 16 additions & 0 deletions src/Libs/Vidyano/Actions/export-to-csv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Vidyano {
"use strict";

export namespace Actions {
export class ExportToCsv extends Action {
constructor(service: Service, definition: ActionDefinition, owner: ServiceObjectWithActions) {
super(service, definition, owner);
}

protected _onExecute({ menuOption, parameters, selectedItems, skipOpen, noConfirmation, throwExceptions }: IActionExecuteOptions): Promise<PersistentObject> {
this.service._getStream(null, "Query.ExportToCsv", this.parent, this.query, null, this._getParameters(parameters, menuOption));
return Promise.resolve(null);
}
}
}
}
16 changes: 16 additions & 0 deletions src/Libs/Vidyano/Actions/export-to-excel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Vidyano {
"use strict";

export namespace Actions {
export class ExportToExcel extends Action {
constructor(service: Service, definition: ActionDefinition, owner: ServiceObjectWithActions) {
super(service, definition, owner);
}

protected _onExecute({ menuOption, parameters, selectedItems, skipOpen, noConfirmation, throwExceptions }: IActionExecuteOptions): Promise<PersistentObject> {
this.service._getStream(null, "Query.ExportToExcel", this.parent, this.query, null, this._getParameters(parameters, menuOption));
return Promise.resolve(null);
}
}
}
}
12 changes: 12 additions & 0 deletions src/Libs/Vidyano/Actions/filter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Vidyano {
"use strict";

export namespace Actions {
export class Filter extends Action {
constructor(service: Service, definition: ActionDefinition, owner: ServiceObjectWithActions) {
super(service, definition, owner);
this.isVisible = false;
}
}
}
}
16 changes: 16 additions & 0 deletions src/Libs/Vidyano/Actions/refresh-query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Vidyano {
"use strict";

export namespace Actions {
export class RefreshQuery extends Action {
constructor(service: Service, definition: ActionDefinition, owner: ServiceObjectWithActions) {
super(service, definition, owner);
this.isVisible = false;
}

protected _onExecute({ menuOption, parameters, selectedItems, skipOpen, noConfirmation, throwExceptions }: IActionExecuteOptions): Promise<any> {
return this.query.search();
}
}
}
}
49 changes: 49 additions & 0 deletions src/Libs/Vidyano/Actions/save.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace Vidyano {
"use strict";

export namespace Actions {
export class Save extends Action {
constructor(service: Service, definition: ActionDefinition, owner: ServiceObjectWithActions) {
super(service, definition, owner);
this.dependentActions = ["CancelSave"];
}

protected async _onExecute({ menuOption, parameters, selectedItems, skipOpen, noConfirmation, throwExceptions }: IActionExecuteOptions): Promise<PersistentObject> {
const wasNew = this.parent.isNew;

await this.parent.save();

// NOTE: Check if operations will open a new persistent object anyway
if (this.service.queuedClientOperations.length > 0 &&
this.service.queuedClientOperations.some(o => {
if (o.type === "Open") {
(<ClientOperations.IOpenOperation>o).replace = true;
return true;
}
else if (o.type === "ExecuteMethod") {
const eo = <ClientOperations.IExecuteMethodOperation>o;
if (eo.name === "navigate") {
eo.arguments[1] = true;
return true;
}
}

return false;
})
)
return this.parent;

if (StringEx.isNullOrWhiteSpace(this.parent.notification) || this.parent.notificationType !== NotificationType.Error) {
if (wasNew && this.parent.ownerAttributeWithReference == null && this.parent.stateBehavior.indexOf("OpenAfterNew") !== -1) {
const newPO = await this.parent.queueWork(() => this.service.getPersistentObject(this.parent.parent, this.parent.id, this.parent.objectId));
this.service.hooks.onOpen(newPO, true);
}
else
this.service.hooks.onClose(this.parent);
}

return this.parent;
}
}
}
}
38 changes: 38 additions & 0 deletions src/Libs/Vidyano/Actions/show-help.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace Vidyano {
"use strict";

export namespace Actions {
export class ShowHelp extends Action {
constructor(service: Service, definition: ActionDefinition, owner: ServiceObjectWithActions) {
super(service, definition, owner);
}

protected async _onExecute({ menuOption, parameters, selectedItems, skipOpen, noConfirmation, throwExceptions }: IActionExecuteOptions): Promise<PersistentObject> {
const owner = this.query ? this.query.persistentObject : this.parent;
const helpWindow = window.open();

try {
const po = await this.service.executeAction("PersistentObject.ShowHelp", owner, null, null);

if (po != null) {
if (po.fullTypeName === "Vidyano.RegisteredStream" || po.getAttributeValue("Type") === "0") {
helpWindow.close();
this.service._getStream(po);
} else {
helpWindow.location.href = po.getAttributeValue("Document");
helpWindow.focus();
}
}
else
helpWindow.close();
}
catch (e) {
helpWindow.close();
this.owner.setNotification(e);
}

return null;
}
}
}
}
15 changes: 15 additions & 0 deletions src/Libs/Vidyano/Actions/vi-configure-po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Vidyano {
"use strict";

export namespace Actions {
/* tslint:disable:class-name */
export class viConfigurePO extends Action {
constructor(service: Service, definition: ActionDefinition, owner: ServiceObjectWithActions) {
super(service, definition, owner);

this.isVisible = false;
}
}
/* tslint:enable:class-name */
}
}
15 changes: 15 additions & 0 deletions src/Libs/Vidyano/Actions/vi-configure-query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Vidyano {
"use strict";

export namespace Actions {
/* tslint:disable:class-name */
export class viConfigureQuery extends Action {
constructor(service: Service, definition: ActionDefinition, owner: ServiceObjectWithActions) {
super(service, definition, owner);

this.isVisible = false;
}
}
/* tslint:enable:class-name */
}
}
18 changes: 18 additions & 0 deletions src/Libs/Vidyano/Actions/vi-search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Vidyano {
"use strict";

export namespace Actions {
/* tslint:disable:class-name */
export class viSearch extends Action {
constructor(service: Service, definition: ActionDefinition, owner: ServiceObjectWithActions) {
super(service, definition, owner);

this.isVisible = this.parent == null || this.parent.fullTypeName === "Vidyano.Search";

if (this.parent != null && this.parent.fullTypeName === "Vidyano.Search")
this._isPinned = false;
}
}
/* tslint:enable:class-name */
}
}
9 changes: 9 additions & 0 deletions src/Libs/Vidyano/ClientOperations/i-client-operation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Vidyano {
"use strict";

export namespace ClientOperations {
export interface IClientOperation {
type: string;
}
}
}
Loading

0 comments on commit eba5ae6

Please sign in to comment.