Update prettier

This commit is contained in:
FinnStutzenstein 2019-06-12 08:01:33 +02:00
parent 5a5264046e
commit 213fc30800
11 changed files with 91 additions and 134 deletions

View File

@ -49,9 +49,9 @@
"hammerjs": "^2.0.8", "hammerjs": "^2.0.8",
"material-icon-font": "git+https://github.com/petergng/materialIconFont.git", "material-icon-font": "git+https://github.com/petergng/materialIconFont.git",
"ng-pick-datetime": "^7.0.0", "ng-pick-datetime": "^7.0.0",
"ng2-pdf-viewer": "^5.2.3",
"ngx-file-drop": "^6.0.0", "ngx-file-drop": "^6.0.0",
"ngx-mat-select-search": "^1.7.2", "ngx-mat-select-search": "^1.7.2",
"ng2-pdf-viewer": "^5.2.3",
"ngx-papaparse": "^3.0.2", "ngx-papaparse": "^3.0.2",
"pdfmake": "^0.1.53", "pdfmake": "^0.1.53",
"po2json": "^1.0.0-alpha", "po2json": "^1.0.0-alpha",
@ -83,7 +83,7 @@
"karma-jasmine-html-reporter": "^1.4.0", "karma-jasmine-html-reporter": "^1.4.0",
"npm-license-crawler": "^0.2.1", "npm-license-crawler": "^0.2.1",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"prettier": "^1.17.0", "prettier": "^1.18.0",
"protractor": "^5.4.2", "protractor": "^5.4.2",
"source-map-explorer": "^1.7.0", "source-map-explorer": "^1.7.0",
"ts-node": "~8.1.0", "ts-node": "~8.1.0",

View File

@ -111,9 +111,7 @@ export class AppLoadService {
// to check if the result of the contructor (the model instance) is really a searchable. // to check if the result of the contructor (the model instance) is really a searchable.
if (!isSearchable(new entry.viewModel())) { if (!isSearchable(new entry.viewModel())) {
throw Error( throw Error(
`Wrong configuration for ${ `Wrong configuration for ${entry.collectionString}: you gave a searchOrder, but the model is not searchable.`
entry.collectionString
}: you gave a searchOrder, but the model is not searchable.`
); );
} }
return true; return true;

View File

@ -112,9 +112,7 @@ export class ItemRepositoryService extends BaseHasContentObjectRepository<
return contentObject; return contentObject;
} else { } else {
throw new Error( throw new Error(
`The content object (${agendaItem.content_object.collection}, ${ `The content object (${agendaItem.content_object.collection}, ${agendaItem.content_object.id}) of item ${agendaItem.id} is not a BaseAgendaItemViewModel.`
agendaItem.content_object.id
}) of item ${agendaItem.id} is not a BaseAgendaItemViewModel.`
); );
} }
} }

View File

@ -130,9 +130,7 @@ export class ListOfSpeakersRepositoryService extends BaseHasContentObjectReposit
return contentObject; return contentObject;
} else { } else {
throw new Error( throw new Error(
`The content object (${listOfSpeakers.content_object.collection}, ${ `The content object (${listOfSpeakers.content_object.collection}, ${listOfSpeakers.content_object.id}) of list of speakers ${listOfSpeakers.id} is not a BaseListOfSpeakersViewModel.`
listOfSpeakers.content_object.id
}) of list of speakers ${listOfSpeakers.id} is not a BaseListOfSpeakersViewModel.`
); );
} }
} }

View File

@ -238,9 +238,7 @@ export class ConfigRepositoryService extends BaseRepository<ViewConfig, Config,
item.config = keyConfigMap[item.key]; item.config = keyConfigMap[item.key];
} else if (check) { } else if (check) {
throw new Error( throw new Error(
`No config variable found for "${ `No config variable found for "${item.key}". Please migrate the database or rebuild the servercache.`
item.key
}". Please migrate the database or rebuild the servercache.`
); );
} }
} }
@ -251,9 +249,7 @@ export class ConfigRepositoryService extends BaseRepository<ViewConfig, Config,
item.config = keyConfigMap[item.key]; item.config = keyConfigMap[item.key];
} else if (check) { } else if (check) {
throw new Error( throw new Error(
`No config variable found for "${ `No config variable found for "${item.key}". Please migrate the database or rebuild the servercache.`
item.key
}". Please migrate the database or rebuild the servercache.`
); );
} }
} }

View File

@ -465,15 +465,11 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo
*/ */
public amendmentsTo(motionId: number): Observable<ViewMotion[]> { public amendmentsTo(motionId: number): Observable<ViewMotion[]> {
return this.getViewModelListObservable().pipe( return this.getViewModelListObservable().pipe(
map( map((motions: ViewMotion[]): ViewMotion[] => {
(motions: ViewMotion[]): ViewMotion[] => { return motions.filter((motion: ViewMotion): boolean => {
return motions.filter( return motion.parent_id === motionId;
(motion: ViewMotion): boolean => { });
return motion.parent_id === motionId; })
}
);
}
)
); );
} }

View File

@ -967,21 +967,18 @@ export class DiffService {
* @returns {string} * @returns {string}
*/ */
public addCSSClassToFirstTag(html: string, className: string): string { public addCSSClassToFirstTag(html: string, className: string): string {
return html.replace( return html.replace(/<[a-z][^>]*>/i, (match: string): string => {
/<[a-z][^>]*>/i, if (match.match(/class=["'][a-z0-9 _-]*["']/i)) {
(match: string): string => { return match.replace(
if (match.match(/class=["'][a-z0-9 _-]*["']/i)) { /class=["']([a-z0-9 _-]*)["']/i,
return match.replace( (match2: string, previousClasses: string): string => {
/class=["']([a-z0-9 _-]*)["']/i, return 'class="' + previousClasses + ' ' + className + '"';
(match2: string, previousClasses: string): string => { }
return 'class="' + previousClasses + ' ' + className + '"'; );
} } else {
); return match.substring(0, match.length - 1) + ' class="' + className + '">';
} else {
return match.substring(0, match.length - 1) + ' class="' + className + '">';
}
} }
); });
} }
/** /**
@ -1031,13 +1028,11 @@ export class DiffService {
const styles = node.getAttribute('style'); const styles = node.getAttribute('style');
if (styles && styles.indexOf('color') > -1) { if (styles && styles.indexOf('color') > -1) {
const stylesNew = []; const stylesNew = [];
styles.split(';').forEach( styles.split(';').forEach((style: string): void => {
(style: string): void => { if (!style.match(/^\s*color\s*:/i)) {
if (!style.match(/^\s*color\s*:/i)) { stylesNew.push(style);
stylesNew.push(style);
}
} }
); });
if (stylesNew.join(';') === '') { if (stylesNew.join(';') === '') {
node.removeAttribute('style'); node.removeAttribute('style');
} else { } else {
@ -1060,24 +1055,21 @@ export class DiffService {
* @returns {string} * @returns {string}
*/ */
private addClassToHtmlTag(tagStr: string, className: string): string { private addClassToHtmlTag(tagStr: string, className: string): string {
return tagStr.replace( return tagStr.replace(/<(\w+)( [^>]*)?>/gi, (whole: string, tag: string, tagArguments: string): string => {
/<(\w+)( [^>]*)?>/gi, tagArguments = tagArguments ? tagArguments : '';
(whole: string, tag: string, tagArguments: string): string => { if (tagArguments.match(/class="/gi)) {
tagArguments = tagArguments ? tagArguments : ''; // class="someclass" => class="someclass insert"
if (tagArguments.match(/class="/gi)) { tagArguments = tagArguments.replace(
// class="someclass" => class="someclass insert" /(class\s*=\s*)(["'])([^\2]*)\2/gi,
tagArguments = tagArguments.replace( (classWhole: string, attr: string, para: string, content: string): string => {
/(class\s*=\s*)(["'])([^\2]*)\2/gi, return attr + para + content + ' ' + className + para;
(classWhole: string, attr: string, para: string, content: string): string => { }
return attr + para + content + ' ' + className + para; );
} } else {
); tagArguments += ' class="' + className + '"';
} else {
tagArguments += ' class="' + className + '"';
}
return '<' + tag + tagArguments + '>';
} }
); return '<' + tag + tagArguments + '>';
});
} }
/** /**

View File

@ -409,17 +409,15 @@ export class LinenumberingService {
}); });
} }
} }
return headings.sort( return headings.sort((heading1: SectionHeading, heading2: SectionHeading): number => {
(heading1: SectionHeading, heading2: SectionHeading): number => { if (heading1.lineNumber < heading2.lineNumber) {
if (heading1.lineNumber < heading2.lineNumber) { return 0;
return 0; } else if (heading1.lineNumber > heading2.lineNumber) {
} else if (heading1.lineNumber > heading2.lineNumber) { return 1;
return 1; } else {
} else { return 0;
return 0;
}
} }
); });
} }
/** /**
@ -476,11 +474,9 @@ export class LinenumberingService {
*/ */
public splitToParagraphs(html: string): string[] { public splitToParagraphs(html: string): string[] {
const fragment = this.htmlToFragment(html); const fragment = this.htmlToFragment(html);
return this.splitNodeToParagraphs(fragment).map( return this.splitNodeToParagraphs(fragment).map((node: Element): string => {
(node: Element): string => { return node.outerHTML;
return node.outerHTML; });
}
);
} }
/** /**

View File

@ -85,11 +85,9 @@ export class AgendaSortComponent extends SortTreeViewComponent<ViewItem> impleme
*/ */
const filter = this.activeFilters.subscribe((value: number[]) => { const filter = this.activeFilters.subscribe((value: number[]) => {
this.hasActiveFilter = value.length === 0 ? false : true; this.hasActiveFilter = value.length === 0 ? false : true;
this.changeFilter.emit( this.changeFilter.emit((item: ViewItem): boolean => {
(item: ViewItem): boolean => { return !(value.includes(item.type) || value.length === 0);
return !(value.includes(item.type) || value.length === 0); });
}
);
}); });
this.subscriptions.push(filter); this.subscriptions.push(filter);
} }

View File

@ -164,17 +164,15 @@ export class AmendmentCreateWizardComponent extends BaseViewComponent {
} else { } else {
newParagraphs = Object.assign([], oldSelected); newParagraphs = Object.assign([], oldSelected);
newParagraphs.push(paragraph); newParagraphs.push(paragraph);
newParagraphs.sort( newParagraphs.sort((para1: ParagraphToChoose, para2: ParagraphToChoose): number => {
(para1: ParagraphToChoose, para2: ParagraphToChoose): number => { if (para1.paragraphNo < para2.paragraphNo) {
if (para1.paragraphNo < para2.paragraphNo) { return -1;
return -1; } else if (para1.paragraphNo > para2.paragraphNo) {
} else if (para1.paragraphNo > para2.paragraphNo) { return 1;
return 1; } else {
} else { return 0;
return 0;
}
} }
); });
this.contentForm.addControl( this.contentForm.addControl(
'text_' + paragraph.paragraphNo, 'text_' + paragraph.paragraphNo,
@ -206,16 +204,14 @@ export class AmendmentCreateWizardComponent extends BaseViewComponent {
*/ */
public async saveAmendment(): Promise<void> { public async saveAmendment(): Promise<void> {
let text = ''; let text = '';
const amendedParagraphs = this.paragraphs.map( const amendedParagraphs = this.paragraphs.map((paragraph: ParagraphToChoose, index: number): string => {
(paragraph: ParagraphToChoose, index: number): string => { if (this.contentForm.value.selectedParagraphs.find(para => para.paragraphNo === index)) {
if (this.contentForm.value.selectedParagraphs.find(para => para.paragraphNo === index)) { text = this.contentForm.value['text_' + index];
text = this.contentForm.value['text_' + index]; return this.contentForm.value['text_' + index];
return this.contentForm.value['text_' + index]; } else {
} else { return null;
return null;
}
} }
); });
const newMotionValues = { const newMotionValues = {
...this.contentForm.value, ...this.contentForm.value,
title: this.translate.instant('Amendment to') + ' ' + this.motion.identifier, title: this.translate.instant('Amendment to') + ' ' + this.motion.identifier,

View File

@ -568,22 +568,18 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
this.allChangingObjects = []; this.allChangingObjects = [];
if (this.changeRecommendations) { if (this.changeRecommendations) {
this.changeRecommendations.forEach( this.changeRecommendations.forEach((change: ViewUnifiedChange): void => {
(change: ViewUnifiedChange): void => { this.allChangingObjects.push(change);
this.allChangingObjects.push(change); });
}
);
} }
if (this.amendments) { if (this.amendments) {
this.amendments.forEach( this.amendments.forEach((amendment: ViewMotion): void => {
(amendment: ViewMotion): void => { this.repo
this.repo.getAmendmentAmendedParagraphs(amendment, this.lineLength).forEach( .getAmendmentAmendedParagraphs(amendment, this.lineLength)
(change: ViewUnifiedChange): void => { .forEach((change: ViewUnifiedChange): void => {
this.allChangingObjects.push(change); this.allChangingObjects.push(change);
} });
); });
}
);
} }
this.allChangingObjects.sort((a: ViewUnifiedChange, b: ViewUnifiedChange) => { this.allChangingObjects.sort((a: ViewUnifiedChange, b: ViewUnifiedChange) => {
if (a.getLineFrom() < b.getLineFrom()) { if (a.getLineFrom() < b.getLineFrom()) {
@ -618,12 +614,10 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
} }
} }
}), }),
this.repo.amendmentsTo(motionId).subscribe( this.repo.amendmentsTo(motionId).subscribe((amendments: ViewMotion[]): void => {
(amendments: ViewMotion[]): void => { this.amendments = amendments;
this.amendments = amendments; this.recalcUnifiedChanges();
this.recalcUnifiedChanges(); }),
}
),
this.changeRecoRepo this.changeRecoRepo
.getChangeRecosOfMotionObservable(motionId) .getChangeRecosOfMotionObservable(motionId)
.subscribe((recos: ViewMotionChangeRecommendation[]) => { .subscribe((recos: ViewMotionChangeRecommendation[]) => {
@ -688,20 +682,15 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
if (parentMotion && this.lineLength) { if (parentMotion && this.lineLength) {
const paragraphsToChoose = this.repo.getParagraphsToChoose(parentMotion, this.lineLength); const paragraphsToChoose = this.repo.getParagraphsToChoose(parentMotion, this.lineLength);
paragraphsToChoose.forEach( paragraphsToChoose.forEach((paragraph: ParagraphToChoose, paragraphNo: number): void => {
(paragraph: ParagraphToChoose, paragraphNo: number): void => { if (formMotion.amendment_paragraphs[paragraphNo] !== null) {
if (formMotion.amendment_paragraphs[paragraphNo] !== null) { this.contentForm.addControl('text_' + paragraphNo, new FormControl('', Validators.required));
this.contentForm.addControl(
'text_' + paragraphNo,
new FormControl('', Validators.required)
);
contentPatch.selected_paragraphs.push(paragraph); contentPatch.selected_paragraphs.push(paragraph);
contentPatch.text = formMotion.amendment_paragraphs[paragraphNo]; // Workaround as 'text' is required from the backend contentPatch.text = formMotion.amendment_paragraphs[paragraphNo]; // Workaround as 'text' is required from the backend
contentPatch['text_' + paragraphNo] = formMotion.amendment_paragraphs[paragraphNo]; contentPatch['text_' + paragraphNo] = formMotion.amendment_paragraphs[paragraphNo];
}
} }
); });
} }
} }