+ [class.uk-disabled]="numberIndicatorPaths.at(i).get('url').invalid"
+ (click)="validateJsonPath(i, true)">
diff --git a/src/app/topic/indicators.component.ts b/src/app/topic/indicators.component.ts
index 75e0ece..322dd87 100644
--- a/src/app/topic/indicators.component.ts
+++ b/src/app/topic/indicators.component.ts
@@ -30,6 +30,7 @@ import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sideb
import {Router} from "@angular/router";
import {Session} from "../openaireLibrary/login/utils/helper.class";
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
+import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
declare var UIkit;
@@ -172,6 +173,14 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
result = result[jsonPath];
}
});
+ if (typeof result === 'string' || typeof result === 'number') {
+ result = Number(result);
+ if (result === Number.NaN) {
+ result = 0;
+ }
+ } else {
+ result = 0;
+ }
this.numberResults.set(i + '-' + j, result);
});
}));
@@ -431,7 +440,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
public addJsonPath(index: number) {
if (index == 0 && this.getJsonPath(index).getRawValue()[index].indexOf(",") != -1) {
- //if in the first path there are more than one paaths comma separated, split them and autogenerate the forms
+ //if in the first path there are more than one paths comma separated, split them and autogenerate the forms
let paths = this.getJsonPath(index).getRawValue()[index].split(",");
for (let i = 0; i < paths.length; i++) {
if (i != 0) {
@@ -439,19 +448,18 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
}
}
this.getJsonPath(index).setValue(paths)
- return;
+ } else {
+ this.getJsonPath(index).push(this.fb.control('', Validators.required));
}
- this.getJsonPath(index).push(this.fb.control('', Validators.required));
}
public removeJsonPath(i: number, j: number) {
- this.getJsonPath(i).removeAt(j);
- if (this.getJsonPath(i).length !== this.getCurrentJsonPath(i).length) {
- this.getJsonPath(i).markAsDirty();
+ if(this.getJsonPath(i).enabled) {
+ this.getJsonPath(i).removeAt(j);
}
}
- public validateJsonPath(index: number) {
+ public validateJsonPath(index: number, dirty: boolean = false) {
let indicatorPath: FormGroup =
this.numberIndicatorPaths.at(index);
if (this.indicator.defaultId === null) {
this.getJsonPath(index).disable();
@@ -467,20 +475,33 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
setTimeout(() => {
if (this.indicator.defaultId === null) {
this.getJsonPath(index).enable();
+ if(dirty) {
+ this.getJsonPath(index).markAsDirty();
+ }
}
indicatorPath.get('result').setErrors(null);
- console.debug(result);
if (typeof result === 'string' || typeof result === 'number') {
result = Number(result);
if (result !== Number.NaN) {
indicatorPath.get('result').setValue(result);
} else {
- indicatorPath.get('result').setValue(null);
+ indicatorPath.get('result').setValue(0);
}
} else {
- indicatorPath.get('result').setValue(null);
+ indicatorPath.get('result').setValue(0);
}
}, 500);
+ }, error => {
+ setTimeout(() => {
+ if (this.indicator.defaultId === null) {
+ this.getJsonPath(index).enable();
+ if (dirty) {
+ this.getJsonPath(index).markAsDirty();
+ }
+ }
+ indicatorPath.get('result').setErrors(null);
+ indicatorPath.get('result').setValue(0);
+ }, 500);
}));
}
@@ -514,7 +535,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
jsonPath.push(this.fb.control('', Validators.required));
}
this.numberIndicatorPaths.push(this.fb.group({
- url: this.fb.control(url, Validators.required),
+ url: this.fb.control(url, [Validators.required, StringUtils.urlValidator()]),
jsonPath: jsonPath,
result: this.fb.control(0, Validators.required),
// parameters: parameters,
@@ -587,10 +608,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
public addChartIndicatorPath(value: string = '', parameters: FormArray = new FormArray([]), disableUrl: boolean = false, type: string = null) {
this.chartIndicatorPaths.push(this.fb.group({
- url: this.fb.control(value, [Validators.required,
- Validators.pattern('https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.' +
- '[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.' +
- '[a-zA-Z0-9]+\.[^\s]{2,}')]),
+ url: this.fb.control(value, [Validators.required, StringUtils.urlValidator()]),
parameters: parameters,
type: this.fb.control(type)
}
diff --git a/src/app/topic/topic.component.html b/src/app/topic/topic.component.html
index e663e2d..30d166b 100644
--- a/src/app/topic/topic.component.html
+++ b/src/app/topic/topic.component.html
@@ -57,7 +57,7 @@
- Create new topic
+ 0" class="space" [class.uk-hidden]="!open"> Create new topic
@@ -141,7 +141,7 @@
- Create new category
+ 0" class="space">Create new category
@@ -194,7 +194,7 @@
- Create new subcategory
+ 0" class="space">Create new subcategory
diff --git a/src/assets/dashboard-theme/input.css b/src/assets/dashboard-theme/input.css
index 1f86274..0e94bbd 100644
--- a/src/assets/dashboard-theme/input.css
+++ b/src/assets/dashboard-theme/input.css
@@ -10,7 +10,7 @@
}
.input-box {
- background-color: #FAFAFA;
+ background-color: #FAFAFA !important;
border: 1px solid transparent;
padding: 16px;
border-radius: 4px;
diff --git a/src/assets/new.css b/src/assets/new.css
index 8379d88..df04c13 100644
--- a/src/assets/new.css
+++ b/src/assets/new.css
@@ -10,7 +10,6 @@
--primary-color-rgb: var(--theme-secondary-color-rgb);
--secondary-color-rgb: var(--theme-secondary-color-rgb);
}
-
/*Stakeholder Specific*/
.publicationsSearchForm {
background-image: none;
@@ -145,9 +144,10 @@
max-width: 50px;
background: var(--secondary-color);
color: var(--contrast-color);
- -webkit-clip-path: polygon(15% 5%, 100% 5%, 100% 100%, 0% 100%);
+ -webkit-clip-path: polygon(20% 5%, 80% 5%, 100% 100%, 0% 100%);
clip-path: polygon(20% 5%, 80% 5%, 100% 100%, 0% 100%);
display: none;
+ padding-left: 10px;
}
.dashboard .section {