Skip to content

Commit

Permalink
Merge pull request #4067 from FinnStutzenstein/prettify
Browse files Browse the repository at this point in the history
Using prettify instead of pretty-quick-wrapper
  • Loading branch information
jsaalfeld committed Jan 10, 2019
2 parents b01b20f + 1c895fb commit 2f7336b
Show file tree
Hide file tree
Showing 95 changed files with 515 additions and 505 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ matrix:
install:
- npm install
script:
- npm run prettify-all
- npm run prettify-check

- language: node_js
name: "Client: Testing"
Expand Down
5 changes: 2 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"compodoc": "./node_modules/.bin/compodoc --hideGenerator -p src/tsconfig.app.json -n 'OpenSlides Documentation' -d ../Compodoc -s -w -t -o --port",
"extract": "ngx-translate-extract -i ./src -o ./src/assets/i18n/template-en.pot -clean --sort --format pot -m _",
"po2json": "./node_modules/.bin/po2json -f mf src/assets/i18n/de.po src/assets/i18n/de.json && ./node_modules/.bin/po2json -f mf src/assets/i18n/cs.po src/assets/i18n/cs.json",
"prettify-changes": "pretty-quick --staged",
"prettify-all": "pretty-quick"
"prettify-check": "prettier --config ./.prettierrc --list-different \"src/{app,environments}/**/*{.ts,.js,.json,.css,.scss}\"",
"prettify-write": "prettier --config ./.prettierrc --write \"src/{app,environments}/**/*{.ts,.js,.json,.css,.scss}\""
},
"dependencies": {
"@angular/animations": "^7.1.1",
Expand Down Expand Up @@ -71,7 +71,6 @@
"karma-jasmine-html-reporter": "^0.2.2",
"npm-run-all": "^4.1.5",
"prettier": "^1.15.3",
"pretty-quick": "^1.8.0",
"protractor": "^5.4.1",
"ts-node": "~7.0.1",
"tslint": "~5.11.0",
Expand Down
1 change: 0 additions & 1 deletion client/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export class AppComponent {
* TODO: Overloading can be extended to more functions.
*/
private overloadArrayToString(): void {

Array.prototype.toString = function(): string {
let string = '';
const iterations = Math.min(this.length, 3);
Expand Down
30 changes: 19 additions & 11 deletions client/src/app/core/marked-translations.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// import { _ } from '@biesbjerg/ngx-translate-extract';

function _(key: string | string[]): string | string[] {
return key;
return key;
}

/**
Expand All @@ -19,10 +19,12 @@ function _(key: string | string[]): string | string[] {
// Core config strings
_('Presentation and assembly system');
_('Event name');
_('<a href="http://www.openslides.org">OpenSlides</a> is a free ' +
_(
'<a href="http://www.openslides.org">OpenSlides</a> is a free ' +
'web based presentation and assembly system for visualizing ' +
'and controlling agenda, motions and elections of an ' +
'assembly.');
'assembly.'
);
_('General');
_('Event');
_('Short description of event');
Expand Down Expand Up @@ -94,7 +96,6 @@ _('Public item');
_('Internal item');
_('Hidden item');


// Motions config strings
// subgroup general
_('General');
Expand All @@ -115,13 +116,17 @@ _('Hide recommendation on projector');
_('Stop submitting new motions by non-staff users');
_('Allow to disable versioning');
_('Name of recommender');
_('Will be displayed as label before selected recommendation. Use an empty value to disable the recommendation system.');
_(
'Will be displayed as label before selected recommendation. Use an empty value to disable the recommendation system.'
);
_('Name of recommender for statute amendments');
_('Will be displayed as label before selected recommendation for statute amendments. Use an empty value to disable the recommendation system.');
_(
'Will be displayed as label before selected recommendation for statute amendments. Use an empty value to disable the recommendation system.'
);
_('Default text version for change recommendations');
// subgroup Amendments
_('Amendments');
_('Activate statute amendments')
_('Activate statute amendments');
_('Activate amendments');
_('Show amendments together with motions');
_('Prefix for the identifier for amendments');
Expand Down Expand Up @@ -210,7 +215,6 @@ _('Called with');
_('Recommendation');
_('Motion block');


// Assignment config strings
_('Election method');
_('Automatic assign of method');
Expand All @@ -220,10 +224,12 @@ _('Always Yes/No per candidate');
_('Elections');
_('Ballot and ballot papers');
_('The 100-%-base of an election result consists of');
_('For Yes/No/Abstain per candidate and Yes/No per candidate the 100-%-base ' +
_(
'For Yes/No/Abstain per candidate and Yes/No per candidate the 100-%-base ' +
'depends on the election method: If there is only one option per candidate, ' +
'the sum of all votes of all candidates is 100 %. Otherwise for each ' +
'candidate the sum of all votes is 100 %.');
'candidate the sum of all votes is 100 %.'
);
_('Yes/No/Abstain per candidate');
_('Yes/No per candidate');
_('All valid ballots');
Expand Down Expand Up @@ -316,7 +322,9 @@ _('Email subject');
_('Your login for {event_name}');
_('You can use {event_name} as a placeholder.');
_('Email body');
_('Dear {name},\n\nthis is your OpenSlides login for the event {event_name}:\n\n {url}\n username: {username}\n password: {password}\n\nThis email was generated automatically.');
_(
'Dear {name},\n\nthis is your OpenSlides login for the event {event_name}:\n\n {url}\n username: {username}\n password: {password}\n\nThis email was generated automatically.'
);
_('Use these placeholders: {name}, {event_name}, {url}, {username}, {password}. The url referrs to the system url.');

// default groups
Expand Down
1 change: 0 additions & 1 deletion client/src/app/core/query-params.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

type QueryParamValue = string | number | boolean;

/**
Expand Down
6 changes: 5 additions & 1 deletion client/src/app/core/services/app-load.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ export class AppLoadService {
// between (ModelConstructor<BaseModel>) and (new (...args: any[]) => (BaseModel & Searchable)), we would not have
// to check if the result of the contructor (the model instance) is really a searchable.
if (!isSearchable(new entry.model())) {
throw Error(`Wrong configuration for ${entry.collectionString}: you gave a searchOrder, but the model is not searchable.`);
throw Error(
`Wrong configuration for ${
entry.collectionString
}: you gave a searchOrder, but the model is not searchable.`
);
}
return true;
}
Expand Down
56 changes: 30 additions & 26 deletions client/src/app/core/services/csv-export.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,40 +115,44 @@ export class CsvExportService {
csvContent.push(header);

// create lines
csvContent = csvContent.concat(models.map(model => {
return columns.map(column => {
let value: string;

if (isPropertyDefinition(column)) {
const property: any = model[column.property];
if (typeof property === 'number') {
value = property.toString(10);
} else if (!property) {
value = '';
} else if (property === true) {
value = '1';
} else if (property === false) {
value = '0';
} else {
value = property.toString();
csvContent = csvContent.concat(
models.map(model => {
return columns.map(column => {
let value: string;

if (isPropertyDefinition(column)) {
const property: any = model[column.property];
if (typeof property === 'number') {
value = property.toString(10);
} else if (!property) {
value = '';
} else if (property === true) {
value = '1';
} else if (property === false) {
value = '0';
} else {
value = property.toString();
}
} else if (isMapDefinition(column)) {
value = column.map(model);
}
} else if (isMapDefinition(column)) {
value = column.map(model);
}
tsList = this.checkCsvTextSafety(value, tsList);
tsList = this.checkCsvTextSafety(value, tsList);

return value;
});
}));
return value;
});
})
);

// assemble lines, putting text separator in place
if (!tsList.length) {
throw new Error('no usable text separator left for valid csv text');
}

const csvContentAsString: string = csvContent.map(line => {
return line.map(entry => tsList[0] + entry + tsList[0]).join(columnSeparator);
}).join(lineSeparator);
const csvContentAsString: string = csvContent
.map(line => {
return line.map(entry => tsList[0] + entry + tsList[0]).join(columnSeparator);
})
.join(lineSeparator);
this.exporter.saveFile(csvContentAsString, filename);
}

Expand Down
6 changes: 4 additions & 2 deletions client/src/app/core/services/data-store.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ export class DataStoreService {
/**
* Observable subject for changed or deleted models in the datastore.
*/
private readonly changedOrDeletedSubject: Subject<BaseModel | DeletedInformation> = new Subject<BaseModel | DeletedInformation>();
private readonly changedOrDeletedSubject: Subject<BaseModel | DeletedInformation> = new Subject<
BaseModel | DeletedInformation
>();

/**
* Observe the datastore for changes and deletions.
Expand Down Expand Up @@ -358,7 +360,7 @@ export class DataStoreService {
collection: collectionString,
id: +id // needs casting, because Objects.keys gives all keys as strings...
});
})
});
});
if (models && models.length) {
await this.add(models, newMaxChangeId);
Expand Down

0 comments on commit 2f7336b

Please sign in to comment.