Skip to content

Commit

Permalink
Merge pull request sillsdev#271 from sillsdev/refactor/lexiconAppComp…
Browse files Browse the repository at this point in the history
…onent

Refactor lexicon app to TypeScript and Angular component
  • Loading branch information
irahopkinson authored May 31, 2018
2 parents c82716f + e54fddb commit 32d1b7d
Show file tree
Hide file tree
Showing 19 changed files with 336 additions and 996 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
25 changes: 15 additions & 10 deletions src/angular-app/languageforge/lexicon/core/lexicon-core.module.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import * as angular from 'angular';

import { LexiconConfigService } from './lexicon-config.service';
import { LexiconEditorDataService } from './lexicon-editor-data.service';
import { LexiconEntryApiService } from './lexicon-entry-api.service';
import { LexiconLinkService } from './lexicon-link.service';
import { LexiconProjectService } from './lexicon-project.service';
import { LexiconRightsService } from './lexicon-rights.service';
import { LexiconSendReceiveApiService } from './lexicon-send-receive-api.service';
import { LexiconSendReceiveService } from './lexicon-send-receive.service';
import { LexiconUtilityService } from './lexicon-utility.service';
import {BreadcrumbModule} from '../../../bellows/core/breadcrumbs/breadcrumb.module';
import {CoreModule} from '../../../bellows/core/core.module';
import {LexiconConfigService} from './lexicon-config.service';
import {LexiconEditorDataService} from './lexicon-editor-data.service';
import {LexiconEntryApiService} from './lexicon-entry-api.service';
import {LexiconLinkService} from './lexicon-link.service';
import {LexiconProjectService} from './lexicon-project.service';
import {LexiconRightsService} from './lexicon-rights.service';
import {LexiconSendReceiveApiService} from './lexicon-send-receive-api.service';
import {LexiconSendReceiveService} from './lexicon-send-receive.service';
import {LexiconUtilityService} from './lexicon-utility.service';

export const LexiconCoreModule = angular
.module('lexiconCoreModule', [])
.module('lexiconCoreModule', [
BreadcrumbModule,
CoreModule
])
.service('lexProjectService', LexiconProjectService)
.service('lexLinkService', LexiconLinkService)
.service('lexConfigService', LexiconConfigService)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as angular from 'angular';

import {LexiconCoreModule} from '../../core/lexicon-core.module';
import {CommentBubbleComponent} from './comment-bubble.component';
import {CommentsRightPanelComponent} from './comments-right-panel.component';
import {CurrentEntryCommentCountComponent} from './current-entry-comment-count.component';
Expand All @@ -8,7 +9,9 @@ import {LexCommentsViewComponent} from './lex-comments-view.component';
import {RegardingFieldComponent} from './regarding-field.component';

export const EditorCommentsModule = angular
.module('lexCommentsModule', [])
.module('lexCommentsModule', [
LexiconCoreModule
])
.component('commentBubble', CommentBubbleComponent)
.component('commentsRightPanel', CommentsRightPanelComponent)
.component('currentEntryCommentCount', CurrentEntryCommentCountComponent)
Expand Down
13 changes: 8 additions & 5 deletions src/angular-app/languageforge/lexicon/editor/editor.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {ActivityAppModule} from '../../../bellows/apps/activity/activity-app.mod
import {CoreModule} from '../../../bellows/core/core.module';
import {NoticeModule} from '../../../bellows/core/notice/notice.module';
import {PuiUtilityModule} from '../../../bellows/shared/utils/pui-utils.module';
import {LexiconCoreModule} from '../core/lexicon-core.module';
import {EditorCommentsModule} from './comment/comment.module';
import {LexiconEditorComponent, LexiconEditorEntryController, LexiconEditorListController} from './editor.component';
import {EditorFieldModule} from './field/field.module';
Expand All @@ -17,6 +18,8 @@ export const LexiconEditorModule = angular
CoreModule,
NoticeModule,
PuiUtilityModule,
'palaso.ui.typeahead',
LexiconCoreModule,
EditorCommentsModule,
EditorFieldModule
])
Expand All @@ -31,11 +34,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
Expand Up @@ -3,6 +3,7 @@ import * as angular from 'angular';
import {NoticeModule} from '../../../../bellows/core/notice/notice.module';
import {MockModule} from '../../../../bellows/shared/mock.module';
import {SoundModule} from '../../../../bellows/shared/sound.module';
import {LexiconCoreModule} from '../../core/lexicon-core.module';
import {EditorCommentsModule} from '../comment/comment.module';
import {FieldAudioComponent} from './dc-audio.component';
import {FieldEntryComponent} from './dc-entry.component';
Expand All @@ -21,10 +22,11 @@ import {FieldTextComponent} from './dc-text.component';
export const EditorFieldModule = angular
.module('editorFieldModule', [
'ngFileUpload',
EditorCommentsModule,
MockModule,
NoticeModule,
SoundModule
SoundModule,
LexiconCoreModule,
EditorCommentsModule
])
.component('dcAudio', FieldAudioComponent)
.component('dcEntry', FieldEntryComponent)
Expand Down
Empty file.
Loading

0 comments on commit 32d1b7d

Please sign in to comment.