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",
"material-icon-font": "git+https://github.com/petergng/materialIconFont.git",
"ng-pick-datetime": "^7.0.0",
"ng2-pdf-viewer": "^5.2.3",
"ngx-file-drop": "^6.0.0",
"ngx-mat-select-search": "^1.7.2",
"ng2-pdf-viewer": "^5.2.3",
"ngx-papaparse": "^3.0.2",
"pdfmake": "^0.1.53",
"po2json": "^1.0.0-alpha",
@ -83,7 +83,7 @@
"karma-jasmine-html-reporter": "^1.4.0",
"npm-license-crawler": "^0.2.1",
"npm-run-all": "^4.1.5",
"prettier": "^1.17.0",
"prettier": "^1.18.0",
"protractor": "^5.4.2",
"source-map-explorer": "^1.7.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.
if (!isSearchable(new entry.viewModel())) {
throw Error(
`Wrong configuration for ${
entry.collectionString
}: you gave a searchOrder, but the model is not searchable.`
`Wrong configuration for ${entry.collectionString}: you gave a searchOrder, but the model is not searchable.`
);
}
return true;

View File

@ -112,9 +112,7 @@ export class ItemRepositoryService extends BaseHasContentObjectRepository<
return contentObject;
} else {
throw new Error(
`The content object (${agendaItem.content_object.collection}, ${
agendaItem.content_object.id
}) of item ${agendaItem.id} is not a BaseAgendaItemViewModel.`
`The content object (${agendaItem.content_object.collection}, ${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;
} else {
throw new Error(
`The content object (${listOfSpeakers.content_object.collection}, ${
listOfSpeakers.content_object.id
}) of list of speakers ${listOfSpeakers.id} is not a BaseListOfSpeakersViewModel.`
`The content object (${listOfSpeakers.content_object.collection}, ${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];
} else if (check) {
throw new Error(
`No config variable found for "${
item.key
}". Please migrate the database or rebuild the servercache.`
`No config variable found for "${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];
} else if (check) {
throw new Error(
`No config variable found for "${
item.key
}". Please migrate the database or rebuild the servercache.`
`No config variable found for "${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[]> {
return this.getViewModelListObservable().pipe(
map(
(motions: ViewMotion[]): ViewMotion[] => {
return motions.filter(
(motion: ViewMotion): boolean => {
return motion.parent_id === motionId;
}
);
}
)
map((motions: ViewMotion[]): ViewMotion[] => {
return motions.filter((motion: ViewMotion): boolean => {
return motion.parent_id === motionId;
});
})
);
}

View File

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

View File

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

View File

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

View File

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

View File

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