no message

This commit is contained in:
Ioannis Kalyvas 2018-01-24 16:11:09 +02:00
parent 00a1f80f01
commit c6e2e8aec4
9 changed files with 66 additions and 28 deletions

View File

@ -2,6 +2,7 @@ package eu.eudat.controllers;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import eu.eudat.entities.DMP;
@ -40,7 +41,8 @@ public class Datasets extends BaseController {
}
@RequestMapping(method = RequestMethod.POST, value = {"/datasets/getPaged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody ResponseEntity<ResponseItem<DataTableData<DatasetListingModel>>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest, Principal principal) {
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DatasetListingModel>>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest, Principal principal) {
try {
DataTableData<DatasetListingModel> dataTable = new DatasetManager().getPaged(this.getApiContext(), datasetTableRequest, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
@ -53,10 +55,11 @@ public class Datasets extends BaseController {
@Transactional
@RequestMapping(method = RequestMethod.GET, value = {"/datasets/makepublic/{id}"}, produces = "application/json")
public @ResponseBody ResponseEntity<ResponseItem<Dataset>> makePublic(@PathVariable UUID id, Principal principal) {
public @ResponseBody
ResponseEntity<ResponseItem<Dataset>> makePublic(@PathVariable UUID id, Principal principal, Locale locale) {
try {
DatasetManager.makePublic(this.getApiContext().getDatabaseRepository().getDatasetDao(), id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Dataset Has Been Made Public"));
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message(this.getApiContext().getMessageSource().getMessage("dataset.public", new Object[]{}, locale)));
} catch (Exception ex) {
ex.printStackTrace();

View File

@ -2,6 +2,7 @@ package eu.eudat.services;
import eu.eudat.proxy.fetching.RemoteFetcher;
import org.springframework.context.ApplicationContext;
import org.springframework.context.MessageSource;
/**
* Created by ikalyvas on 1/3/2018.
@ -12,4 +13,5 @@ public interface ApiContext {
InvitationService getInvitationService();
RemoteFetcher getRemoteFetcher();
MailService getMailService();
MessageSource getMessageSource();
}

View File

@ -3,6 +3,7 @@ package eu.eudat.services;
import eu.eudat.proxy.fetching.RemoteFetcher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Service;
/**
@ -16,6 +17,7 @@ public class ApiContextImpl implements ApiContext{
private RemoteFetcher remoteFetcher;
private InvitationService invitationService;
private MailService mailService;
private MessageSource messageSource;
@Autowired
public void setDatabaseRepository(DatabaseRepository databaseRepository) {
@ -67,4 +69,13 @@ public class ApiContextImpl implements ApiContext{
this.mailService = mailService;
}
@Override
public MessageSource getMessageSource() {
return messageSource;
}
@Autowired
public void setMessageSource(MessageSource messageSource) {
this.messageSource = messageSource;
}
}

View File

@ -4,4 +4,5 @@ projectTableRequest.periodStart.overlapping = Period Start cannot overlap Period
projectTableRequest.offset.negative=table offset cannot be negative
projectTableRequest.length.negative=table length cannot be negative
datasetprofile.label.null = Dataset Profile Label cannot be null
project.startDate.overlapping = Period Start cannot overlap Period End
project.startDate.overlapping = Period Start cannot overlap Period
dataset.public = Dataset Has Been Made Public

View File

@ -1,2 +1,8 @@
datamanagementplanrequest.length.negative=Το πληθος των σειρων στο table δεν μπορει να ειναι αρνητικο
datamanagementplanrequest.offset.negative=Το offset των τιμων δεν μπορει να ειναι αρνητικο
datamanagementplanrequest.length.negative= Το μέγεθος του table δεν μπορει να ειναι αρνητικο
datamanagementplanrequest.offset.negative= Το offset του table δεν μπορει να ειναι αρνητικο
projectTableRequest.periodStart.overlapping = Η Αρχικη Περιοδος δεν μπορει να ειναι Μεγαλυτερη της τελικης
projectTableRequest.offset.negative= Το offset του table δεν μπορει να ειναι αρνητικο
projectTableRequest.length.negative= Το μέγεθος του table δεν μπορει να ειναι αρνητικο
datasetprofile.label.null = Το ονομα του ορισμου ενος Dataset δεν μπορει να ειναι κενο
project.startDate.overlapping = Η Αρχικη Περιοδος δεν μπορει να ειναι Μεγαλυτερη της τελικης
dataset.public = Το Dataset δημοσιοποιηθηκε σε ολους

View File

@ -19,7 +19,7 @@ import { RuleStyle } from '../../entities/common/rulestyle';
encapsulation: ViewEncapsulation.None
})
export class DynamicFormFieldComponent {
export class DynamicFormFieldComponent implements OnInit{
@Input() field: Field;
@Input() form: FormGroup;
@Input() pathName:string;
@ -27,6 +27,11 @@ export class DynamicFormFieldComponent {
constructor(private route: ActivatedRoute,private visibilityRulesService:VisibilityRulesService) { }
ngOnInit(){
this.form.get('value').valueChanges.subscribe(item => {
this.visibilityRulesService.updateValueAndVisibility(this.field.id)
})
}
ngOnChanges(changeRecord) {

View File

@ -27,7 +27,7 @@ export class InvitationComponent implements OnInit {
private invitationService: InvitationService,
private route: ActivatedRoute,
public router: Router,
public dialogRef: MatDialogRef<InvitationComponent>,
public dialogRef: MatDialogRef<InvitationComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) { }
@ -40,7 +40,7 @@ export class InvitationComponent implements OnInit {
send(value: any) {
this.invitationService.inviteUsers(this.formGroup.value).subscribe(
null,null,()=>this.dialogRef.close()
null, null, () => this.dialogRef.close()
);
}

View File

@ -1,5 +1,5 @@
import { VisibilityRuleSource } from './VisibilityRuleSource';
export class VisibilityRule{
public targetControlId:string;
public sourceVisibilityRules:Array<VisibilityRuleSource>
export class VisibilityRule {
public targetControlId: string;
public sourceVisibilityRules: Array<VisibilityRuleSource>
}

View File

@ -9,33 +9,43 @@ export class VisibilityRulesService {
public formGroup: FormGroup;
public visibilityRuleContext: VisibilityRulesContext;
public fieldsPathMemory: any = {};
private elementVisibilityMap = new Map<String, boolean>();
public isElementVisible(pathKey: string, id: string) {
if (!this.fieldsPathMemory[id] && pathKey) this.fieldsPathMemory[id] = pathKey;
let visibilityRule = this.visibilityRuleContext.getRulesFromKey(id);
if (!visibilityRule) return true;
if (this.checkElementVisibility(visibilityRule)) {
if (this.checkElementVisibility(id)) {
return true
} else {
this.clearValues(pathKey)
// if (pathKey && this.formGroup.get(pathKey + '.value')) this.formGroup.get(pathKey + '.value').patchValue(null)
return false;
}
}
public checkElementVisibility(visibilityRule: VisibilityRule): boolean {
let sourceVisibilityRules = visibilityRule.sourceVisibilityRules;
for (let i = 0; i < sourceVisibilityRules.length; i++) {
let sourceVisibilityRule = sourceVisibilityRules[i];
if (!this.formGroup.get(this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value')) return false; //TODO
if (sourceVisibilityRule.sourceControlValue != '' + this.formGroup.get(this.fieldsPathMemory[sourceVisibilityRule.sourceControlId] + '.value').value) return false;
}
return true;
public checkElementVisibility(id: string): boolean {
if (!this.elementVisibilityMap.has(id) || this.elementVisibilityMap.get(id)) return true;
else return false;
}
public buildVisibilityRules(item: Array<Rule>) {
this.visibilityRuleContext = new VisibilityRulesContext();
this.visibilityRuleContext.buildVisibilityRuleContext(item);
this.visibilityRuleContext.rules.forEach(item => this.evaluateVisibility(item))
}
public updateValueAndVisibility(id: string) {
let visibilityRules = this.visibilityRuleContext.rules.filter(item => item.sourceVisibilityRules.filter(source => source.sourceControlId === id).length > 0);
visibilityRules.forEach(item => this.evaluateVisibility(item))
}
private evaluateVisibility(visibilityRule: VisibilityRule) {
for (let i = 0; i < visibilityRule.sourceVisibilityRules.length; i++) {
let pathKey = this.fieldsPathMemory[visibilityRule.sourceVisibilityRules[i].sourceControlId];
if (this.formGroup.get(pathKey + '.value') && this.formGroup.get(pathKey + '.value').value != '' + visibilityRule.sourceVisibilityRules[i].sourceControlValue) {
this.elementVisibilityMap.set(visibilityRule.targetControlId, false)
} else {
this.elementVisibilityMap.set(visibilityRule.targetControlId, true)
}
}
}
private getParentPath(parentId: string): string {
@ -44,10 +54,10 @@ export class VisibilityRulesService {
private clearValues(pathKey) {
if (pathKey && this.formGroup.get(pathKey + '.value')) this.formGroup.get(pathKey + '.value').patchValue(null)
if (pathKey && this.formGroup.get(pathKey)["controls"].fields){
if (pathKey && this.formGroup.get(pathKey)["controls"].fields) {
for (var i = 0; i < this.formGroup.get(pathKey)["controls"].fields.length; i++)
this.clearValues(pathKey+'.fields.'+i);
}
this.clearValues(pathKey + '.fields.' + i);
}
}
}