Skip to content

Commit

Permalink
Refactor lexicon app to Angular component
Browse files Browse the repository at this point in the history
  • Loading branch information
irahopkinson committed May 31, 2018
1 parent af8a599 commit 7d59429
Show file tree
Hide file tree
Showing 7 changed files with 233 additions and 250 deletions.
16 changes: 11 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions src/angular-app/bellows/core/offline/editor-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class EntryListModifiers {
}

export class EditorDataService {
readonly browserInstanceId = Math.floor(Math.random() * 1000000);
readonly browserInstanceId: string = Math.floor(Math.random() * 1000000).toString();

entries: any[] = [];
visibleEntries: any[] = [];
Expand Down Expand Up @@ -80,15 +80,14 @@ export class EditorDataService {
/**
* Called when loading the controller
*/
loadEditorData = (lexiconScope?: any): angular.IPromise<any> => {
loadEditorData = (): angular.IPromise<any> => {
const deferred = this.$q.defer();
if (this.entries.length === 0) { // first page load
if (this.cache.canCache()) {
this.notice.setLoading('Loading Dictionary');
this.loadDataFromOfflineCache().then((projectObj: any) => {
if (projectObj.isComplete) {
this.showInitialEntries().then(() => {
lexiconScope.finishedLoading = true;
this.notice.cancelLoading();
this.refreshEditorData(projectObj.timestamp).then((result: any) => {
deferred.resolve(result);
Expand Down Expand Up @@ -256,7 +255,7 @@ export class EditorDataService {
UtilityService.arrayCopyRetainingReferences(entriesSorted, this.entries);
const filteredEntriesSorted = this.sortList(config, this.filteredEntries);
UtilityService.arrayCopyRetainingReferences(filteredEntriesSorted, this.filteredEntries);
const visibleEntriesSorted = this.sortList(config, this.visibleEntries);
this.sortList(config, this.visibleEntries);
if (shouldResetVisibleEntriesList) {
// TODO: Magic number "50" below should become a constant somewhere
UtilityService.arrayCopyRetainingReferences(filteredEntriesSorted.slice(0, 50), this.visibleEntries);
Expand Down
10 changes: 5 additions & 5 deletions src/angular-app/languageforge/lexicon/editor/editor.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export const LexiconEditorModule = angular
abstract: true,
url: '/editor',
template: `
<lexicon-editor lec-config="editorConfig"
lec-interface-config="interfaceConfig"
lec-finished-loading="finishedLoading"
lec-project="project"
lec-rights="rights"></lexicon-editor>`
<lexicon-editor lec-config="$ctrl.editorConfig"
lec-interface-config="$ctrl.interfaceConfig"
lec-finished-loading="$ctrl.finishedLoading"
lec-project="$ctrl.project"
lec-rights="$ctrl.rights"></lexicon-editor>`
})
.state('editor.list', {
url: '/list',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="content container-fluid" data-ng-cloak dir="{{$ctrl.interfaceConfig.direction}}">
<div id="lexicon-hmenu">
<div class="lexnav form-group"></div>
</div>

<sil-notices></sil-notices>
<div data-ui-view></div>
</div>
Loading

0 comments on commit 7d59429

Please sign in to comment.