Skip to content

Commit

Permalink
fix up some handling of statics
Browse files Browse the repository at this point in the history
  • Loading branch information
dickschoeller committed Aug 7, 2018
1 parent 74a1ba5 commit 5a1ff60
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
16 changes: 8 additions & 8 deletions gedbrowserng-frontend/src/app/utils/api-comparators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ import { ApiNote, ApiSource, ApiPerson, ApiSubmitter } from '../models';

export class ApiComparators {
public static comparePersons(a: ApiPerson, b: ApiPerson) {
return this.compare(a.indexName, a.string, b.indexName, b.string);
return ApiComparators.compare(a.indexName, a.string, b.indexName, b.string);
}

public static compareSources(a: ApiSource, b: ApiSource) {
return this.compare(a.title, a.string, b.title, b.string);
return ApiComparators.compare(a.title, a.string, b.title, b.string);
}

public static compareSubmitters(a: ApiSubmitter, b: ApiSubmitter) {
return this.compare(a.name, a.string, b.name, b.string);
return ApiComparators.compare(a.name, a.string, b.name, b.string);
}

public static compareNotes(a: ApiNote, b: ApiNote) {
return this.compare(a.tail, a.string, b.tail, b.string);
return ApiComparators.compare(a.tail, a.string, b.tail, b.string);
}

private static compare (a1: string, a2: string, b1: string, b2: string) {
const val = this.strip(a1).localeCompare(this.strip(b1));
public static compare (a1: string, a2: string, b1: string, b2: string) {
const val = ApiComparators.strip(a1).localeCompare(ApiComparators.strip(b1));
if (val !== 0) {
return val;
}
return this.strip(a2).localeCompare(this.strip(b2));
return ApiComparators.strip(a2).localeCompare(ApiComparators.strip(b2));
}

private static strip(a: string): string {
public static strip(a: string): string {
if (a === undefined) {
return '';
}
Expand Down
2 changes: 1 addition & 1 deletion gedbrowserng-frontend/src/app/utils/new-note-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export class NewNoteHelper {
}

public static initNew(text: string): NewNoteDialogData {
return {text: text};
return { text: text };
}
}
14 changes: 7 additions & 7 deletions gedbrowserng-frontend/src/app/utils/new-person-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { AttributeDialogHelper } from './attribute-dialog-helper';
export class NewPersonHelper {
public static buildPerson(data: NewPersonDialogData): ApiPerson {
if (StringUtil.isEmpty(data.name)) {
data.name = this.defaultGiven(data.sex);
data.name = NewPersonHelper.defaultGiven(data.sex);
}
const person: ApiPerson = new ApiPerson();
person.attributes = new Array<ApiAttribute>();
this.addName(data.name, person);
this.addSex(data.sex, person);
this.addBirth(data.birthDate, data.birthPlace, person);
this.addDeath(data.deathDate, data.deathPlace, person);
NewPersonHelper.addName(data.name, person);
NewPersonHelper.addSex(data.sex, person);
NewPersonHelper.addBirth(data.birthDate, data.birthPlace, person);
NewPersonHelper.addDeath(data.deathDate, data.deathPlace, person);
return person;
}

Expand Down Expand Up @@ -58,7 +58,7 @@ export class NewPersonHelper {

public static initNew(sex: string, surname: string): NewPersonDialogData {
return {
sex: sex, name: this.defaultGiven(sex) + '/' + surname + '/',
sex: sex, name: NewPersonHelper.defaultGiven(sex) + '/' + surname + '/',
birthDate: '', birthPlace: '', deathDate: '', deathPlace: ''
};
}
Expand All @@ -70,7 +70,7 @@ export class NewPersonHelper {
public static guessPartnerSex(person: ApiPerson): string {
for (const a of person.attributes) {
if (a.string === 'Sex') {
return this.oppositeSex(a.tail);
return NewPersonHelper.oppositeSex(a.tail);
}
}
return 'M';
Expand Down
14 changes: 7 additions & 7 deletions gedbrowserng-frontend/src/app/utils/new-source-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { StringUtil } from './string-util';
export class NewSourceHelper {
public static buildSource(data: NewSourceDialogData): ApiSource {
if (StringUtil.isEmpty(data.title)) {
data.title = this.defaultTitle(data);
data.title = NewSourceHelper.defaultTitle(data);
}
const source: ApiSource = new ApiSource();
source.attributes = new Array<ApiAttribute>();
this.addTitle(data.title, source);
this.addAbbreviation(data.abbreviation, source);
this.addText(data.text, source);
NewSourceHelper.addTitle(data.title, source);
NewSourceHelper.addAbbreviation(data.abbreviation, source);
NewSourceHelper.addText(data.text, source);
return source;
}

Expand All @@ -34,12 +34,12 @@ export class NewSourceHelper {
source.attributes.push(adh.simpleAttribute('Text', text));
}

private static config(dataIn) {
return {data: dataIn};
public static config(dataIn) {
return { data: dataIn };
}

public static initNew(title: string): NewSourceDialogData {
return {title: title, abbreviation: title, text: ''};
return { title: title, abbreviation: title, text: '' };
}

private static empty(result): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class NewSubmitterHelper {
}
const submitter: ApiSubmitter = new ApiSubmitter();
submitter.attributes = new Array<ApiAttribute>();
this.addName(data.name, submitter);
NewSubmitterHelper.addName(data.name, submitter);
return submitter;
}

Expand Down
10 changes: 5 additions & 5 deletions gedbrowserng-frontend/src/app/utils/string-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ export class StringUtil {
public static titleCase (target: string): string {
const strSplit = target.split(' ');
for (let i = 0; i < strSplit.length; i++) {
this.capitalizeSplit(strSplit, i);
StringUtil.capitalizeSplit(strSplit, i);
}
return strSplit.join(' ');
}

private static capitalizeSplit(strSplit, i): void {
let s: string = strSplit[i];
if (i === 0 || i === strSplit.length - 1) {
s = this.capitalize(s);
} else if (!this.allcaps(s)) {
s = StringUtil.capitalize(s);
} else if (!StringUtil.allcaps(s)) {
// Note all caps wins over donotcap, otherwise 'OR' gets mishandled as 'or'.
s = this.capitalize(s);
} else if (this.donotcap(s)) {
s = StringUtil.capitalize(s);
} else if (StringUtil.donotcap(s)) {
s = s.toLowerCase();
}
strSplit[i] = s;
Expand Down

0 comments on commit 5a1ff60

Please sign in to comment.