How to use the aurelia-framework.singleton function in aurelia-framework

To help you get started, we’ve selected a few aurelia-framework examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ghiscoding / aurelia-slickgrid / dist / native-modules / services / resizer.service.js View on Github external
// compensate anytime SlickGrid measureScrollbar is incorrect
                this.compensateHorizontalScroll(this._grid, this._gridOptions);
            }
            // keep last resized dimensions & resolve them to the Promise
            this._lastDimensions = {
                height: newHeight,
                width: newWidth
            };
            if ((this._gridOptions.enablePagination || this._gridOptions.backendServiceApi)) {
                this._lastDimensions.heightWithPagination = newHeight + DATAGRID_PAGINATION_HEIGHT;
            }
        }
        return this._lastDimensions;
    };
    ResizerService = __decorate([
        singleton(true),
        inject(EventAggregator)
    ], ResizerService);
    return ResizerService;
}());
export { ResizerService };
github ghiscoding / aurelia-slickgrid / src / aurelia-slickgrid / services / sort.service.ts View on Github external
FieldType,
  GridOption,
  SortDirection,
  CurrentSorter,
  SlickEventHandler,
  SortDirectionNumber,
  SortDirectionString,
} from './../models/index';
import { executeBackendCallback, refreshBackendDataset } from './backend-utilities';
import { getDescendantProperty } from './utilities';
import { sortByFieldType } from '../sorters/sorterUtilities';

// using external non-typed js libraries
declare var Slick: any;

@singleton(true)
@inject(EventAggregator)
export class SortService {
  private _currentLocalSorters: CurrentSorter[] = [];
  private _eventHandler: SlickEventHandler;
  private _dataView: any;
  private _grid: any;
  private _isBackendGrid = false;

  constructor(private ea: EventAggregator) {
    this._eventHandler = new Slick.EventHandler();
  }

  /** Getter of the SlickGrid Event Handler */
  get eventHandler(): SlickEventHandler {
    return this._eventHandler;
  }
github ghiscoding / aurelia-slickgrid / dist / commonjs / extensions / cellExternalCopyManagerExtension.js View on Github external
CellExternalCopyManagerExtension.prototype.hookUndoShortcutKey = function () {
        var _this = this;
        // undo shortcut
        $(document).keydown(function (e) {
            if (e.which === 90 && (e.ctrlKey || e.metaKey)) { // CTRL + (shift) + Z
                if (e.shiftKey) {
                    _this.undoRedoBuffer.redo();
                }
                else {
                    _this.undoRedoBuffer.undo();
                }
            }
        });
    };
    CellExternalCopyManagerExtension = __decorate([
        aurelia_framework_1.singleton(true),
        aurelia_framework_1.inject(extensionUtility_1.ExtensionUtility, shared_service_1.SharedService)
    ], CellExternalCopyManagerExtension);
    return CellExternalCopyManagerExtension;
}());
exports.CellExternalCopyManagerExtension = CellExternalCopyManagerExtension;
github ghiscoding / aurelia-slickgrid / src / aurelia-slickgrid / extensions / rowMoveManagerExtension.ts View on Github external
import { singleton, inject } from 'aurelia-framework';
import { CellArgs, Extension, ExtensionName, SlickEventHandler } from '../models/index';
import { ExtensionUtility } from './extensionUtility';
import { SharedService } from '../services/shared.service';

// using external non-typed js libraries
declare var Slick: any;

@singleton(true)
@inject(ExtensionUtility, SharedService)
export class RowMoveManagerExtension implements Extension {
  private _addon: any;
  private _eventHandler: SlickEventHandler;

  constructor(private extensionUtility: ExtensionUtility, private sharedService: SharedService) {
    this._eventHandler = new Slick.EventHandler();
  }

  get eventHandler(): SlickEventHandler {
    return this._eventHandler;
  }

  dispose() {
    // unsubscribe all SlickGrid events
    this._eventHandler.unsubscribeAll();
github ghiscoding / aurelia-slickgrid / dist / es2015 / services / extension.service.js View on Github external
const collection = newColumnDefinitions || this.sharedService.columnDefinitions;
        if (Array.isArray(collection) && this.sharedService.grid && this.sharedService.grid.setColumns) {
            this.sharedService.grid.setColumns(collection);
        }
    }
    /** Translate the an array of items from an input key and assign to the output key */
    translateItems(items, inputKey, outputKey) {
        for (const item of items) {
            if (item[inputKey]) {
                item[outputKey] = this.i18n.tr(item[inputKey]);
            }
        }
    }
};
ExtensionService = __decorate([
    singleton(true),
    inject(AutoTooltipExtension, CellExternalCopyManagerExtension, CheckboxSelectorExtension, ColumnPickerExtension, DraggableGroupingExtension, GridMenuExtension, GroupItemMetaProviderExtension, I18N, HeaderButtonExtension, HeaderMenuExtension, RowDetailViewExtension, RowMoveManagerExtension, RowSelectionExtension, SharedService)
], ExtensionService);
export { ExtensionService };
//# sourceMappingURL=extension.service.js.map
github ghiscoding / aurelia-slickgrid / dist / commonjs / extensions / headerMenuExtension.js View on Github external
}
    };
    /**
     * @return default Header Menu options
     */
    HeaderMenuExtension.prototype.getDefaultHeaderMenuOptions = function () {
        return {
            autoAlignOffset: 12,
            minWidth: 140,
            hideColumnHideCommand: false,
            hideSortCommands: false,
            title: ''
        };
    };
    HeaderMenuExtension = __decorate([
        aurelia_framework_1.singleton(true),
        aurelia_framework_1.inject(extensionUtility_1.ExtensionUtility, aurelia_i18n_1.I18N, shared_service_1.SharedService, sort_service_1.SortService)
    ], HeaderMenuExtension);
    return HeaderMenuExtension;
}());
exports.HeaderMenuExtension = HeaderMenuExtension;
github ghiscoding / aurelia-slickgrid / src / aurelia-slickgrid / services / excelExport.service.ts View on Github external
ExcelStylesheet,
  ExcelWorkbook,
  ExcelWorksheet,
  FileType,
  Formatter,
  GridOption,
  KeyTitlePair,
  Locale,
  FieldType,
} from '../models/index';
import { Constants } from '../constants';
import { addWhiteSpaces, sanitizeHtmlToText, titleCase, mapMomentDateFormatWithFieldType } from './utilities';

const DEFAULT_AURELIA_EVENT_PREFIX = 'asg';

@singleton(true)
@inject(Optional.of(I18N), EventAggregator)
export class ExcelExportService {
  private _aureliaEventPrefix: string;
  private _fileFormat = FileType.xlsx;
  private _dataView: any;
  private _grid: any;
  private _locales: Locale;
  private _columnHeaders: KeyTitlePair[];
  private _groupedHeaders: KeyTitlePair[];
  private _hasGroupedItems = false;
  private _excelExportOptions: ExcelExportOption;
  private _sheet: ExcelWorksheet;
  private _stylesheet: ExcelStylesheet;
  private _stylesheetFormats: any;
  private _workbook: ExcelWorkbook;
github ghiscoding / aurelia-slickgrid / dist / commonjs / services / odata.service.js View on Github external
if (Array.isArray(sortBy)) {
                        sortBy.forEach(function (field, index, inputArray) {
                            inputArray[index] = String.titleCase(field);
                        });
                    }
                    else {
                        sortBy = String.titleCase(options[property]);
                    }
                }
                this._odataOptions.orderBy = sortBy;
                this._defaultSortBy = sortBy;
            }
        }
    };
    OdataService = __decorate([
        aurelia_framework_1.singleton(true)
    ], OdataService);
    return OdataService;
}());
exports.OdataService = OdataService;
github ghiscoding / aurelia-slickgrid / dist / es2017 / services / sort.service.js View on Github external
emitSortChanged(sender) {
        if (sender === 'remote' && this._gridOptions && this._gridOptions.backendServiceApi) {
            let currentSorters = [];
            const backendService = this._gridOptions.backendServiceApi.service;
            if (backendService && backendService.getCurrentSorters) {
                currentSorters = backendService.getCurrentSorters();
            }
            this.ea.publish('sortService:sortChanged', currentSorters);
        }
        else if (sender === 'local') {
            this.ea.publish('sortService:sortChanged', this.getCurrentLocalSorters());
        }
    }
};
SortService = __decorate([
    singleton(true),
    inject(EventAggregator)
], SortService);
export { SortService };
//# sourceMappingURL=sort.service.js.map