Verified Commit c562805d authored by chegelba's avatar chegelba Committed by Sandro Lutz
Browse files

Add multi file upload to studydocuments

parent f28726e8
import m from 'mithril';
import { RadioGroup } from 'polythene-mithril';
import { fileInput } from 'amiv-web-ui-components';
import { RadioGroup, Button, List, ListTile } from 'polythene-mithril';
import EditView from '../views/editView';
export default class editDoc extends EditView {
// constructoe^r zu file upload
constructor(vnode) {
super(vnode);
if (!('files' in this.form.data)) {
this.form.data.files = [{ name: 'add file' }];
}
}
view() {
return this.layout([
m('h3', 'Add a New Studydocument'),
...this.form.renderPage({
// uploader
author: { type: 'text', label: 'Author' },
files: { type: 'text', label: 'File' }, // buggy only singel file possible
lecture: { type: 'text', label: 'Lecture' },
title: { type: 'text', label: 'Title' },
professor: { type: 'text', label: 'Professor' },
course_year: { type: 'number', lable: 'Year' }, // semester unterscheidung, plausibility
}),
// department //drop-down-list
m('div', 'Semester'), // formatieren
// lable for RadioGroup: semester
m('div', { style: { color: '#0006', 'font-size': '16px' } }, 'Semester'),
m(RadioGroup, {
name: 'semester',
buttons: [
......@@ -27,7 +29,7 @@ export default class editDoc extends EditView {
{ value: '4', label: '4', defaultChecked: this.form.data.gender === '4' },
{ value: '5', label: '5+', defaultChecked: this.form.data.gender === '5' },
],
onChange: ({ value }) => { console.log(value); this.form.data.gender = value; },
onChange: ({ value }) => { console.log(value); this.form.data.semester = value; },
}),
m(RadioGroup, {
name: 'type',
......@@ -50,7 +52,37 @@ export default class editDoc extends EditView {
}],
onChange: ({ value }) => { console.log(value); this.form.data.gender = value; },
}),
...this.form.renderPage({
lecture: { type: 'text', label: 'Lecture' },
title: { type: 'text', label: 'Title' },
course_year: { type: 'number', label: 'Year' },
professor: { type: 'text', label: 'Professor' },
author: { type: 'text', label: 'Author' },
}),
// file upload: unfinished
m('div', [
m(List, {
tiles: this.form.data.files.map(file => m(ListTile, {
content: [
m(fileInput, this.form.bind({
name: 'new_file',
label: `${file.name}`,
})),
],
})),
}),
// additional file
m(Button, {
label: 'Additional File',
className: 'blue-button',
border: true,
// onclick to be enabled
events: { onclick: () => { this.form.data.files.push({ name: 'add file' }); } },
}),
]),
]);
}
}
......@@ -14,10 +14,14 @@ export default class StudydocTable {
getItemData(data) {
return [
m('div', { style: { width: 'calc(100% - 30em)' } }, data.title),
m('div', { style: { width: 'calc(100% - 32em)' } }, data.title),
m('div', { style: { width: '6em' } }, data.department.toUpperCase()),
m('div', { style: { width: '6em' } }, data.semester),
m('div', { style: { width: '18em' } }, data.lecture),
m('div', { style: { width: '10em' } }, data.lecture),
m('div', { style: { width: '10em' } }, data.files.map((file) => {
const splittedFilenames = file.name.split('.');
return `.${splittedFilenames[splittedFilenames.length - 1]} `;
})),
];
}
......@@ -27,10 +31,11 @@ export default class StudydocTable {
keys: config.tableKeys,
tileContent: this.getItemData,
titles: [
{ text: 'Titel', width: 'calc(100% - 30em)' },
{ text: 'Titel', width: 'calc(100% - 32em)' },
{ text: 'Department', width: '6em' },
{ text: 'Semester', width: '6em' },
{ text: 'Lecture', width: '18em' },
{ text: 'Lecture', width: '10em' },
{ text: 'Files', width: '10em' },
],
onAdd: () => { m.route.set('/newstudydocument'); },
});
......
Supports Markdown
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