To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 5fbcb9dc authored by boian's avatar boian
Browse files

Fixes build error

Upgrades the versions of webpack and related packages and replaces the
optimization in the build process with new methods (same as for
amiv-website instead of uglify-js). Also fixes some new linter errors that appeared because of new eslint-rules.
parent 3f81f53b
......@@ -4,4 +4,6 @@ node_modules/
package-lock.json
.idea/
dist/
\ No newline at end of file
dist/
.DS_Store
......@@ -161,13 +161,14 @@ export class ResourceHandler {
this.schema = JSON.parse(JSON.stringify(getSchema().definitions[
objectNameForResource[this.resource]]));
// readOnly fields should be removed before patch
this.noPatchKeys = Object.keys(this.schema.properties).filter(key =>
this.schema.properties[key].readOnly);
this.noPatchKeys = Object.keys(this.schema.properties).filter(
key => this.schema.properties[key].readOnly,
);
// any field that is a string can be searched
const possibleSearchKeys = Object.keys(this.schema.properties).filter((key) => {
const field = this.schema.properties[key];
return field.type === 'string' && field.format !== 'objectid' &&
field.format !== 'date-time' && !key.startsWith('_');
return field.type === 'string' && field.format !== 'objectid'
&& field.format !== 'date-time' && !key.startsWith('_');
});
// special case for users, we don't allow reverse search by legi or rfid
if (resource === 'users') this.searchKeys = ['firstname', 'lastname', 'nethz'];
......
......@@ -34,8 +34,9 @@ export default class NewBlacklist extends EditView {
constructor({ attrs }) {
super({ attrs: { controller: new NanoController('blacklist'), ...attrs } });
this.userHandler = new ResourceHandler('users', ['firstname', 'lastname', 'email', 'nethz']);
this.userController = new DatalistController((query, search) =>
this.userHandler.get({ search, ...query }));
this.userController = new DatalistController((query, search) => this.userHandler.get(
{ search, ...query },
));
}
beforeSubmit() {
......
......@@ -33,8 +33,7 @@ export default class BlacklistTable {
data.price && m('div', `price: ${data.price}`),
),
m('div', { style: { 'flex-grow': '100' } }),
m('div', (!data.end_time &&
this.ctrl.handler.rights.includes('POST')) && m(Button, {
m('div', (!data.end_time && this.ctrl.handler.rights.includes('POST')) && m(Button, {
// Button to mark this entry as resolved
className: 'blue-row-button',
borders: false,
......@@ -65,8 +64,9 @@ export default class BlacklistTable {
{ text: 'User', width: '18em' },
{ text: 'Detail', width: '9em' },
],
onAdd: (this.ctrl.handler.rights.includes('POST')) ?
() => { m.route.set('/newblacklistentry'); } : false,
onAdd: (this.ctrl.handler.rights.includes('POST')) ? () => {
m.route.set('/newblacklistentry');
} : false,
});
}
}
......@@ -59,8 +59,9 @@ export default class newEvent extends EditView {
// Create a usercontroller to handle the moderator field
this.userHandler = new ResourceHandler('users', ['firstname', 'lastname', 'email', 'nethz']);
this.userController = new DatalistController((query, search) =>
this.userHandler.get({ search, ...query }));
this.userController = new DatalistController((query, search) => this.userHandler.get(
{ search, ...query },
));
// check whether the user has the right to create events or can only propose
this.rightSubmit = !m.route.get().startsWith('/proposeevent');
......@@ -333,8 +334,8 @@ export default class newEvent extends EditView {
onclick: () => {
let index = fieldIndex;
while (`add_fields_text${index + 1}` in this.form.data) {
this.form.data[`add_fields_text${index}`] =
this.form.data[`add_fields_text${index + 1}`];
this.form.data[`add_fields_text${index}`] = this.form.data[
`add_fields_text${index + 1}`];
index += 1;
}
delete this.form.data[`add_fields_text${index}`];
......@@ -487,10 +488,10 @@ export default class newEvent extends EditView {
type: 'boolean',
label: 'Set high Priority',
}),
m('div', 'Please send your announce text additionally via email to info@amiv.ch ' +
'until the new announce tool is ready.'),
m('div', 'Please send an email to info@amiv.ch in order to show your event on' +
'the infoscreen until the new infoscreen tool is ready.'),
m('div', 'Please send your announce text additionally via email to info@amiv.ch '
+ 'until the new announce tool is ready.'),
m('div', 'Please send an email to info@amiv.ch in order to show your event on'
+ 'the infoscreen until the new infoscreen tool is ready.'),
]),
......
......@@ -45,8 +45,8 @@ export default class EventTable {
}]],
// per default, enable the 'upcoming' filter
initFilterIdxs: [[0, 0]],
onAdd: (this.handler.rights.length > 0) ?
() => {
onAdd: (this.handler.rights.length > 0)
? () => {
if (this.handler.rights.includes('POST')) {
m.route.set('/newevent');
} else {
......
......@@ -71,12 +71,13 @@ class ParticipantsSummary {
// Parse the JSON from additional fields into an object
const parsedParticipants = participants.map(signup => ({
...signup,
additional_fields: signup.additional_fields ?
JSON.parse(signup.additional_fields) : {},
additional_fields: signup.additional_fields
? JSON.parse(signup.additional_fields) : {},
}));
// Filter if only accepted participants should be shown
const filteredParticipants = parsedParticipants.filter(participant =>
(this.onlyAccepted ? participant.accepted : true));
const filteredParticipants = parsedParticipants.filter(
participant => (this.onlyAccepted ? participant.accepted : true),
);
// check which additional fields should get summarized
let hasSBB = false;
......@@ -102,22 +103,29 @@ class ParticipantsSummary {
}, 'accepted users'),
])),
hasSBB ? m('div', { style: { display: 'flex' } }, [
m(Property, { title: 'No SBB', leftAlign: false }, filteredParticipants.filter(signup =>
signup.additional_fields.sbb_abo === 'None').length),
m(Property, { title: 'GA', leftAlign: false }, filteredParticipants.filter(signup =>
signup.additional_fields.sbb_abo === 'GA').length),
m(Property, { title: 'Halbtax', leftAlign: false }, filteredParticipants.filter(signup =>
signup.additional_fields.sbb_abo === 'Halbtax').length),
m(Property, { title: 'Gleis 7', leftAlign: false }, filteredParticipants.filter(signup =>
signup.additional_fields.sbb_abo === 'Gleis 7').length),
m(Property, { title: 'No SBB', leftAlign: false }, filteredParticipants.filter(
signup => signup.additional_fields.sbb_abo === 'None',
).length),
m(Property, { title: 'GA', leftAlign: false }, filteredParticipants.filter(
signup => signup.additional_fields.sbb_abo === 'GA',
).length),
m(Property, { title: 'Halbtax', leftAlign: false }, filteredParticipants.filter(
signup => signup.additional_fields.sbb_abo === 'Halbtax',
).length),
m(Property, { title: 'Gleis 7', leftAlign: false }, filteredParticipants.filter(
signup => signup.additional_fields.sbb_abo === 'Gleis 7',
).length),
]) : '',
hasFood ? m('div', { style: { display: 'flex' } }, [
m(Property, { title: 'Omnivors', leftAlign: false }, filteredParticipants.filter(signup =>
signup.additional_fields.food === 'Omnivor').length),
m(Property, { title: 'Vegis', leftAlign: false }, filteredParticipants.filter(signup =>
signup.additional_fields.food === 'Vegi').length),
m(Property, { title: 'Vegans', leftAlign: false }, filteredParticipants.filter(signup =>
signup.additional_fields.food === 'Vegan').length),
m(Property, { title: 'Omnivors', leftAlign: false }, filteredParticipants.filter(
signup => signup.additional_fields.food === 'Omnivor',
).length),
m(Property, { title: 'Vegis', leftAlign: false }, filteredParticipants.filter(
signup => signup.additional_fields.food === 'Vegi',
).length),
m(Property, { title: 'Vegans', leftAlign: false }, filteredParticipants.filter(
signup => signup.additional_fields.food === 'Vegan',
).length),
]) : '',
m('textarea', {
style: { opacity: '0', width: '0px' },
......@@ -147,8 +155,8 @@ class ParticipantsTable {
searchKeys: ['email'],
includeWithoutRelation: true,
});
this.add_fields_schema = additionalFieldsSchema ?
JSON.parse(additionalFieldsSchema).properties : null;
this.add_fields_schema = additionalFieldsSchema
? JSON.parse(additionalFieldsSchema).properties : null;
}
exportAsCSV(filePrefix) {
......@@ -165,8 +173,8 @@ class ParticipantsTable {
item.email,
item.accepted,
item.confirmed,
...Object.keys(this.add_fields_schema || {}).map(key =>
(additionalFields && additionalFields[key] ? additionalFields[key] : '')),
...Object.keys(this.add_fields_schema || {}).map(key => (
additionalFields && additionalFields[key] ? additionalFields[key] : '')),
].join(',');
})).join('\n');
......@@ -198,8 +206,9 @@ class ParticipantsTable {
m(
'div', { style: { width: '16em' } },
m('div', ...data.user ? `Membership: ${data.user.membership}` : ''),
(additionalFields && this.add_fields_schema) ? Object.keys(additionalFields).map(key =>
m('div', `${this.add_fields_schema[key].title}: ${additionalFields[key]}`)) : '',
(additionalFields && this.add_fields_schema) ? Object.keys(additionalFields).map(
key => m('div', `${this.add_fields_schema[key].title}: ${additionalFields[key]}`),
) : '',
),
m('div', { style: { 'flex-grow': '100' } }),
hasPatchRights ? m('div', m(Button, {
......@@ -325,8 +334,8 @@ export default class viewEvent extends ItemView {
// below the title, most important details are listed
m('div.maincontainer', { style: { display: 'flex' } }, [
(this.data.spots !== null && 'signup_count' in this.data
&& this.data.signup_count !== null) ?
m(Property, {
&& this.data.signup_count !== null)
? m(Property, {
style: stdMargin,
title: 'Signups',
}, `${this.data.signup_count} / ${displaySpots}`) : '',
......@@ -379,8 +388,8 @@ export default class viewEvent extends ItemView {
this.data.time_advertising_start ? m(
Property,
{ title: 'Advertising Time' },
`${dateFormatter(this.data.time_advertising_start)} - ` +
`${dateFormatter(this.data.time_advertising_end)}`,
`${dateFormatter(this.data.time_advertising_start)} - `
+ `${dateFormatter(this.data.time_advertising_end)}`,
) : '',
this.data.priority ? m(
Property,
......@@ -394,8 +403,8 @@ export default class viewEvent extends ItemView {
this.data.time_register_start ? m(
Property,
{ title: 'Registration Time' },
`${dateFormatter(this.data.time_register_start)} - ` +
`${dateFormatter(this.data.time_register_end)}`,
`${dateFormatter(this.data.time_register_start)} - `
+ `${dateFormatter(this.data.time_register_end)}`,
) : '',
this.data.selection_strategy ? m(
Property,
......
......@@ -73,8 +73,9 @@ export default class NewGroup extends EditView {
constructor(vnode) {
super(vnode);
this.userHandler = new ResourceHandler('users', ['firstname', 'lastname', 'email', 'nethz']);
this.userController = new DatalistController((query, search) =>
this.userHandler.get({ search, ...query }));
this.userController = new DatalistController((query, search) => this.userHandler.get(
{ search, ...query },
));
}
beforeSubmit() {
......
......@@ -66,8 +66,8 @@ export default class GroupList {
return m('div', [
// groups moderated by the current user
this.moderatedGroups.length > 0 &&
m(GroupListCard, { title: 'moderated by you', groups: this.moderatedGroups }),
this.moderatedGroups.length > 0
&& m(GroupListCard, { title: 'moderated by you', groups: this.moderatedGroups }),
// all groups
m(GroupListCard, {
title: 'all groups',
......
......@@ -29,8 +29,9 @@ class MembersTable {
// true while in the modus of adding a member
this.addmode = false;
this.userHandler = new ResourceHandler('users');
this.userController = new DatalistController((query, search) =>
this.userHandler.get({ search, ...query }));
this.userController = new DatalistController((query, search) => this.userHandler.get(
{ search, ...query },
));
}
itemRow(data) {
......@@ -207,8 +208,8 @@ export default class viewGroup extends ItemView {
...stdMargin,
}, 'has a folder on the AMIV Cloud'),
m('div', { style: { display: 'flex' } }, [
('numMembers' in this) &&
m(Property, { title: 'Members', style: stdMargin }, this.numMembers),
('numMembers' in this)
&& m(Property, { title: 'Members', style: stdMargin }, this.numMembers),
this.data.moderator && m(Property, {
title: 'Moderator',
onclick: () => { m.route.set(`/users/${this.data.moderator._id}`); },
......
......@@ -6,12 +6,12 @@ import EditView from '../views/editView';
export default class newJob extends EditView {
beforeSubmit() {
// remove all unchanged files
if (this.form.data.pdf !== undefined &&
(this.form.data.pdf === null || 'upload_date' in this.form.data.pdf)) {
if (this.form.data.pdf !== undefined
&& (this.form.data.pdf === null || 'upload_date' in this.form.data.pdf)) {
delete this.form.data.pdf;
}
if (this.form.data.logo !== undefined &&
(this.form.data.logo === null || 'upload_date' in this.form.data.logo)) {
if (this.form.data.logo !== undefined
&& (this.form.data.logo === null || 'upload_date' in this.form.data.logo)) {
delete this.form.data.logo;
}
......
......@@ -74,8 +74,9 @@ export default class DatalistController {
this.getPageData(pageNum).then((newPage) => {
pages[pageNum] = newPage;
// look if all pages were collected
const missingPages = Array.from(new Array(totalPages), (x, i) => i + 1).filter(i =>
!(i in pages));
const missingPages = Array.from(new Array(totalPages), (x, i) => i + 1).filter(
i => !(i in pages),
);
console.log('missingPages', missingPages);
if (missingPages.length === 0) {
// collect all the so-far loaded pages in order (sorted keys)
......@@ -102,4 +103,3 @@ export default class DatalistController {
this.refresh();
}
}
......@@ -34,4 +34,3 @@ export function set(key, value, shortSession = false) {
window.localStorage.setItem(`glob-${key}`, value);
}
}
......@@ -85,13 +85,15 @@ export default class RelationlistController {
const secondaryIds = secondaryData._items.map(item => item._id);
// filter the primary list to only include those items that have a relation to
// the queried secondary IDs
const filteredPrimaries = itemsWithRelation.filter(item =>
secondaryIds.includes(item[this.secondaryKey]));
const filteredPrimaries = itemsWithRelation.filter(
item => secondaryIds.includes(item[this.secondaryKey]),
);
// embed the secondary data
const embeddedList = filteredPrimaries.map((item) => {
const itemCopy = Object.assign({}, item);
itemCopy[this.secondaryKey] = secondaryData._items.find(relItem =>
relItem._id === item[this.secondaryKey]);
itemCopy[this.secondaryKey] = secondaryData._items.find(
relItem => relItem._id === item[this.secondaryKey],
);
return itemCopy;
});
// now return the list of filteredPrimaries with the secondary data embedded
......@@ -123,8 +125,9 @@ export default class RelationlistController {
this.getPageData(pageNum).then((newPage) => {
pages[pageNum] = newPage;
// look if all pages were collected
const missingPages = Array.from(new Array(totalPages), (x, i) => i + 1).filter(i =>
!(i in pages));
const missingPages = Array.from(new Array(totalPages), (x, i) => i + 1).filter(
i => !(i in pages),
);
// eslint-disable-next-line no-console
console.log('missingPages', missingPages);
if (missingPages.length === 0) {
......
......@@ -41,4 +41,3 @@ export default class viewDoc extends ItemView {
]));
}
}
......@@ -29,6 +29,7 @@ export class UserTable {
{ sort: [['lastname', 1]] },
);
}
view() {
const tableKeys = ['firstname', 'lastname', 'nethz', 'legi', 'membership'];
return m(TableView, {
......
......@@ -24,8 +24,9 @@ export default class UserView extends ItemView {
this.groupchoice = false;
// a controller to handle the list of possible groups to join
this.groupHandler = new ResourceHandler('groups', ['name']);
this.groupController = new DatalistController((query, search) =>
this.groupHandler.get({ search, ...query }));
this.groupController = new DatalistController(
(query, search) => this.groupHandler.get({ search, ...query }),
);
// exclude the groups where the user is already a member
this.groupmemberships.handler.get({ where: { user: this.data._id } })
.then((data) => {
......
......@@ -80,8 +80,8 @@ export default class EditView extends ItemView {
icon: { svg: { content: m.trust(icons.clear) } },
events: { onclick: () => { this.controller.cancel(); } },
}),
m(ToolbarTitle, `${((this.controller.modus === 'new') ? 'New' : 'Edit')}` +
` ${this.resource.charAt(0).toUpperCase()}${this.resource.slice(1, -1)}`),
m(ToolbarTitle, `${((this.controller.modus === 'new') ? 'New' : 'Edit')}`
+ ` ${this.resource.charAt(0).toUpperCase()}${this.resource.slice(1, -1)}`),
m(Button, {
className: 'blue-button-filled',
extraWide: true,
......
......@@ -55,8 +55,9 @@ export default class TableView {
this.clickOnTitles = clickOnTitles;
this.searchValue = '';
// make a copy of filters so we can toggle the selected status
this.filters = filters ? filters.map(filterGroup =>
filterGroup.map(filter => Object.assign({}, filter))) : null;
this.filters = filters ? filters.map(
filterGroup => filterGroup.map(filter => Object.assign({}, filter)),
) : null;
}
/*
......@@ -105,8 +106,9 @@ export default class TableView {
getSelectedFilterQuery() {
// produce a list of queries from the filters that are currently selected
const selectedFilters = [].concat(...this.filters.map(filterGroup =>
filterGroup.filter(filter => filter.selected === true).map(filter => filter.query)));
const selectedFilters = [].concat(...this.filters.map(filterGroup => filterGroup.filter(
filter => filter.selected === true,
).map(filter => filter.query)));
// now merge all queries into one new object
return Object.assign({}, ...selectedFilters);
}
......@@ -117,8 +119,8 @@ export default class TableView {
if (!controller.sort) return false;
let i;
for (i = 0; i < this.tableTitles.length; i += 1) {
const tableTitlei = this.tableTitles[i].width ?
this.tableTitles[i].text : this.tableTitles[i];
const tableTitlei = this.tableTitles[i].width
? this.tableTitles[i].text : this.tableTitles[i];
if (tableTitlei === titleText) break;
}
return this.tableKeys[i] === controller.sort[0][0];
......@@ -136,8 +138,8 @@ export default class TableView {
style: {
display: 'grid',
height: '100%',
'grid-template-rows': this.filters ?
'48px 40px calc(100% - 120px)' : '48px calc(100% - 80px)',
'grid-template-rows': this.filters
? '48px 40px calc(100% - 120px)' : '48px calc(100% - 80px)',
'background-color': 'white',
},
}, [
......@@ -178,14 +180,14 @@ export default class TableView {
'white-space': 'nowrap',
padding: '0px 5px',
},
}, [].concat(['Filters: '], ...[...this.filters.keys()].map(filterGroupIdx =>
[...this.filters[filterGroupIdx].keys()].map((filterIdx) => {
}, [].concat(['Filters: '], ...[...this.filters.keys()].map(
filterGroupIdx => [...this.filters[filterGroupIdx].keys()].map((filterIdx) => {
const thisFilter = this.filters[filterGroupIdx][filterIdx];
return m(FilterChip, {
selected: thisFilter.selected,
onclick: () => {
if (!thisFilter.selected) {
// set all filters in this group to false
// set all filters in this group to false
[...this.filters[filterGroupIdx].keys()].forEach((i) => {
this.filters[filterGroupIdx][i].selected = false;
});
......@@ -198,7 +200,8 @@ export default class TableView {
controller.setFilter(this.getSelectedFilterQuery());
},
}, thisFilter.name);
})))),
}),
))),
m(List, {
className: 'scrollTable',
style: {
......@@ -224,8 +227,8 @@ export default class TableView {
style: { width: title.width || `${98 / this.tableKeys.length}%` },
},
[title.width ? title.text : title,
this.arrowOrNot(controller, title) ?
m(Icon, { svg: { content: m.trust(icons.sortingArrow) } }) : ''],
this.arrowOrNot(controller, title)
? m(Icon, { svg: { content: m.trust(icons.sortingArrow) } }) : ''],
)),
),
}),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment