Merge pull request #36 in ~VLE2FE/definma-ui from development to master

* commit '1460b5c1e65dead975954ed0b384a395e8c3af45':
  string validation fix for true and false
  small fixes
This commit is contained in:
Veit Lukas (PEA4-Fe) 2020-09-02 15:07:33 +02:00
commit 92a5f483e2
8 changed files with 27 additions and 21 deletions

View File

@ -53,7 +53,8 @@ export class AppComponent implements OnInit{
} }
bugReportContent() { bugReportContent() {
return `mailto:lukas.veit@de.bosch.com?subject=Bug report&body=Thanks for sending the report! Your bug will be (hopefully) fixed soon. return `mailto:${this.d.contact.mail}?subject=Bug report&body=Thanks for sending the report! Your bug will be
(hopefully) fixed soon.
%0D%0A%0D%0A--- REPORT DATA --- %0D%0A%0D%0A--- REPORT DATA ---
%0D%0A%0D%0ATime: ${new Date().toString()}%0D%0A %0D%0A%0D%0ATime: ${new Date().toString()}%0D%0A
URL: ${this.window.location}%0D%0A%0D%0AWhat did you do?%0D%0A${encodeURIComponent(this.bugReport.do)} URL: ${this.window.location}%0D%0A%0D%0AWhat did you do?%0D%0A${encodeURIComponent(this.bugReport.do)}

View File

@ -97,6 +97,8 @@ export class MaterialComponent implements OnInit, AfterContentChecked {
materialSave() { materialSave() {
this.api.put('/material/' + this.material._id, this.material.sendFormat(), () => { this.api.put('/material/' + this.material._id, this.material.sendFormat(), () => {
delete this.d.arr.materials;
this.d.load('materials');
this.router.navigate(['/materials']); this.router.navigate(['/materials']);
}); });
} }

View File

@ -122,14 +122,13 @@ export class RbArrayInputComponent implements ControlValueAccessor, OnInit, Afte
this.values = [this.values[0]]; this.values = [this.values[0]];
res = this.values; res = this.values;
} }
// if (!res.length) { if (!res.length) {
// res = ['']; res = [''];
// } }
this.onChange(res); // trigger ngModel with filled elements this.onChange(res); // trigger ngModel with filled elements
} }
writeValue(obj: any) { // add empty value on init writeValue(obj: any) { // add empty value on init
console.log(obj);
if (obj) { if (obj) {
if (this.pushTemplate !== null) { if (this.pushTemplate !== null) {
if (this.pushPath) { if (this.pushPath) {

View File

@ -339,6 +339,7 @@ export class SamplesComponent implements OnInit {
updateFilterFields(field) { updateFilterFields(field) {
const filter = this.filters.filters.find(e => e.field === field); const filter = this.filters.filters.find(e => e.field === field);
console.log(filter);
filter.active = !(filter.values.length === 1 && filter.values[0] === ''); filter.active = !(filter.values.length === 1 && filter.values[0] === '');
} }

View File

@ -50,7 +50,7 @@ export class ValidationService {
} }
string(data, option = null) { string(data, option = null) {
let validator = Joi.string().max(128).allow(''); let validator = Joi.string().max(128).allow('', true, false);
let errorMsg = 'must contain max 128 characters'; let errorMsg = 'must contain max 128 characters';
if (option === 'alphanum') { if (option === 'alphanum') {
validator = validator.alphanum(); validator = validator.alphanum();

View File

@ -93,24 +93,23 @@ export class TemplatesComponent implements OnInit {
} }
}); });
if (valid) { if (valid) {
console.log('valid', template);
const sendData = {name: template.name, parameters: template.parameters.map(e => omit(e, ['rangeString']))}; const sendData = {name: template.name, parameters: template.parameters.map(e => omit(e, ['rangeString']))};
if (first_id === 'null') { if (first_id === 'null') {
this.api.post<TemplateModel>(`/template/${this.collection}/new`, sendData, data => { this.api.post<TemplateModel>(`/template/${this.collection}/new`, sendData, () => {
if (data.version > template.version) { // there were actual changes and a new version was created delete this.d.arr[this.collection + 'Templates'];
this.templates.push(data); this.d.load(this.collection + 'Templates', () => {
} this.templates = this.d.arr[this.collection + 'Templates'];
this.templateFormat(); this.templateFormat();
this.d.idReload(this.collection + 'Templates'); });
}); });
} }
else { else {
this.api.put<TemplateModel>(`/template/${this.collection}/${template.first_id}`, sendData, data => { this.api.put<TemplateModel>(`/template/${this.collection}/${template.first_id}`, sendData, () => {
if (data.version > template.version) { // there were actual changes and a new version was created delete this.d.arr[this.collection + 'Templates'];
this.templates.push(data); this.d.load(this.collection + 'Templates', () => {
} this.templates = this.d.arr[this.collection + 'Templates'];
this.templateFormat(); this.templateFormat();
this.d.idReload(this.collection + 'Templates'); });
}); });
} }
} }

View File

@ -1,7 +1,7 @@
<rb-icon-button icon="add" mode="primary" (click)="addNewUser()">New user</rb-icon-button> <rb-icon-button icon="add" mode="primary" (click)="addNewUser()" class="space-below">New user</rb-icon-button>
<form *ngIf="newUser" #userForm="ngForm"> <form *ngIf="newUser" #userForm="ngForm" class="space-below">
<rb-form-input name="name" label="user name" appValidate="username" required [(ngModel)]="newUser.name" <rb-form-input name="name" label="user name" appValidate="username" required [(ngModel)]="newUser.name"
#nameInput="ngModel"> #nameInput="ngModel">
<ng-template rbFormValidationMessage="failure">{{nameInput.errors.failure}}</ng-template> <ng-template rbFormValidationMessage="failure">{{nameInput.errors.failure}}</ng-template>

View File

@ -10,3 +10,7 @@ td:last-child rb-icon-button {
width: 100%; width: 100%;
} }
} }
rb-form-select {
min-width: 150px;
}