[plugins-functionality | DONE | CHANGED] give option to for content, deposit or both, use a common form to edit the options + the criteria
This commit is contained in:
parent
7a43b29617
commit
75b4328623
|
@ -36,12 +36,21 @@
|
|||
<div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
|
||||
<div *ngIf="!getCommunityContentProvider(result)">
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<a (click)="addContentProvider(result)" class="uk-button uk-button-link uk-flex uk-flex-middle">
|
||||
<a class="uk-button uk-button-link uk-flex uk-flex-middle">
|
||||
<icon name="add" [flex]="true"></icon>
|
||||
<span class="uk-margin-small-left">
|
||||
Add
|
||||
</span>
|
||||
</a>
|
||||
<div uk-dropdown="mode:click">
|
||||
<ul class="uk-nav uk-dropdown-nav">
|
||||
<li class="uk-nav-header uk-margin-left">Add</li>
|
||||
<li><a (click)="addContentProvider(result,true, false)"> as Content source</a></li>
|
||||
<li ><a (click)="addContentProvider(result,false, true)">as suggestion for Deposit</a></li>
|
||||
<li ><a (click)="addContentProvider(result,true, true)"> Both</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="getCommunityContentProvider(result)">
|
||||
|
|
|
@ -102,8 +102,8 @@ export class AddContentProvidersComponent implements OnInit {
|
|||
"</div>"
|
||||
}
|
||||
|
||||
public addContentProvider(contentProvider: SearchResult) {
|
||||
this.subscriptions.push(this.manageCommunityContentProvidersService.addContentProvider(this.properties, this.community.communityId, contentProvider).subscribe(
|
||||
public addContentProvider(contentProvider: SearchResult, content = true, deposit =false) {
|
||||
this.subscriptions.push(this.manageCommunityContentProvidersService.addContentProvider(this.properties, this.community.communityId, contentProvider, content, deposit).subscribe(
|
||||
data => {
|
||||
this.communityContentProviders.push(data);
|
||||
this._clearCacheService.purgeBrowserCache(this.openAIREEntities.DATASOURCE+" added", this.community.communityId);
|
||||
|
@ -120,7 +120,7 @@ export class AddContentProvidersComponent implements OnInit {
|
|||
|
||||
public removeContentProvider(contentProvider) {
|
||||
let communityContentProvider = this.getCommunityContentProvider(contentProvider);
|
||||
let contentProviderId: string = communityContentProvider['id'];
|
||||
let contentProviderId: string = communityContentProvider['openaireId'];
|
||||
this.subscriptions.push(this.manageCommunityContentProvidersService.removeContentProvider(this.properties, this.community.communityId, contentProviderId).subscribe(
|
||||
data => {
|
||||
let index = this.communityContentProviders.indexOf(communityContentProvider);
|
||||
|
|
|
@ -23,7 +23,7 @@ import {ManageCommunityContentProvidersService} from "../../services/manageConte
|
|||
[communityContentProviders]="communityContentProviders"
|
||||
[loading]="showLoadingInRemove" [community]="community"
|
||||
(editCriteria)="openCriteria($event)"
|
||||
(editDepositInfo)="openDeposit($event)"
|
||||
|
||||
(communityContentProvidersChanged)="communityContentProvidersChanged($event)">
|
||||
</remove-content-providers>
|
||||
<fs-modal #addContentProvidersModal>
|
||||
|
@ -31,10 +31,18 @@ import {ManageCommunityContentProvidersService} from "../../services/manageConte
|
|||
[community]="community"
|
||||
(communityContentProvidersChanged)="communityContentProvidersChanged($event)"></add-content-providers>
|
||||
</fs-modal>
|
||||
<fs-modal #filtersModal (okEmitter)="saveCriteria()" (cancelEmitter)="criteria.reset()"
|
||||
<fs-modal #filtersModal (okEmitter)="saveCriteria()" (cancelEmitter)="criteria.reset(); depositReset();"
|
||||
[okButtonDisabled]="criteria && criteria.disabled">
|
||||
<div class="uk-container uk-container-large">
|
||||
<criteria #criteria *ngIf="dataProvider" [height]="filtersModal.bodyHeight"
|
||||
<mat-slide-toggle [checked]="enabled" (change)="enabled = !enabled"></mat-slide-toggle>
|
||||
<label class="uk-margin-medium-top uk-margin-small-left ">Content source</label>
|
||||
<br>
|
||||
<mat-slide-toggle [checked]="deposit" (change)="deposit = !deposit"></mat-slide-toggle>
|
||||
<label class="uk-margin-medium-top uk-margin-small-left ">Suggest for deposit</label>
|
||||
<div class="uk-width-1-1 uk-margin-medium-top" input placeholder="Type a message or instruction for researchers about deposition in this datasource"
|
||||
[value]="message" (valueChange)="message=$event">
|
||||
</div>
|
||||
<criteria #criteria *ngIf="dataProvider" [height]="filtersModal.bodyHeight - 200"
|
||||
[selectionCriteria]="dataProvider.selectioncriteria">
|
||||
<div no-criteria>
|
||||
<h5 class="uk-margin-small-bottom">No Filters for {{dataProvider.officialname}} yet</h5>
|
||||
|
@ -45,17 +53,6 @@ import {ManageCommunityContentProvidersService} from "../../services/manageConte
|
|||
</criteria>
|
||||
</div>
|
||||
</fs-modal>
|
||||
<fs-modal #depositModal (okEmitter)="saveDepositInfo()" (cancelEmitter)="depositReset()"
|
||||
[okButtonDisabled]="!dataProvider || (message == dataProvider.message && message!=null && deposit == dataProvider.deposit)">
|
||||
<div class="uk-container uk-container-large">
|
||||
<div class="uk-width-1-1" input placeholder="Type a deposit message for researchers"
|
||||
[value]="message" (valueChange)="message=$event">
|
||||
</div>
|
||||
|
||||
<label class="uk-margin-top ">Suggest repository for deposition:</label>
|
||||
<mat-slide-toggle [checked]="deposit" (change)="deposit = !deposit"></mat-slide-toggle>
|
||||
</div>
|
||||
</fs-modal>
|
||||
`
|
||||
})
|
||||
|
||||
|
@ -75,6 +72,7 @@ export class ManageContentProvidersComponent implements OnInit {
|
|||
public dataProvider: ContentProvider;
|
||||
message = "";
|
||||
deposit= false;
|
||||
enabled = false;
|
||||
|
||||
constructor(private title: Title,
|
||||
private cdr: ChangeDetectorRef,
|
||||
|
@ -111,27 +109,22 @@ export class ManageContentProvidersComponent implements OnInit {
|
|||
|
||||
public openCriteria(contentProvider: ContentProvider) {
|
||||
this.dataProvider = contentProvider;
|
||||
this.filtersModal.title = 'Filters';
|
||||
this.deposit = this.dataProvider.deposit;
|
||||
this.message = this.dataProvider.message;
|
||||
this.enabled = this.dataProvider.enabled;
|
||||
this.filtersModal.title = 'Edit datasource Options';
|
||||
this.filtersModal.okButtonText = "Save";
|
||||
this.filtersModal.back = true;
|
||||
this.filtersModal.okButton = true;
|
||||
this.filtersModal.open();
|
||||
this.cdr.detectChanges();
|
||||
}
|
||||
public openDeposit(contentProvider: ContentProvider) {
|
||||
this.dataProvider = contentProvider;
|
||||
this.deposit = this.dataProvider.deposit;
|
||||
this.message = this.dataProvider.message;
|
||||
this.depositModal.title = 'Deposit info';
|
||||
this.depositModal.okButtonText = "Save";
|
||||
this.depositModal.back = true;
|
||||
this.depositModal.okButton = true;
|
||||
this.depositModal.open();
|
||||
this.cdr.detectChanges();
|
||||
}
|
||||
public saveCriteria() {
|
||||
let callback = (selectionCriteria): void => {
|
||||
this.dataProvider.selectioncriteria = selectionCriteria;
|
||||
this.dataProvider.deposit = this.deposit;
|
||||
this.dataProvider.message = this.message;
|
||||
this.dataProvider.enabled = this.enabled;
|
||||
this.manageCommunityContentProvidersService.saveContentProvider(this.properties, this.dataProvider).subscribe(() => {
|
||||
this.criteria.reset();
|
||||
this.removeContentProvidersComponent.getCommunityContentProviders();
|
||||
|
@ -154,20 +147,10 @@ export class ManageContentProvidersComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
|
||||
saveDepositInfo(){
|
||||
this.dataProvider.deposit = this.deposit;
|
||||
this.dataProvider.message = this.message;
|
||||
console.log(this.message)
|
||||
this.manageCommunityContentProvidersService.saveContentProvider(this.properties, this.dataProvider).subscribe(() => {
|
||||
this.removeContentProvidersComponent.getCommunityContentProviders();
|
||||
NotificationHandler.rise('Deposit info have been <b>successfully updated</b>');
|
||||
}, error => {
|
||||
this.criteria.handeError('An error has been occurred. Try again later!', error);
|
||||
});
|
||||
}
|
||||
|
||||
depositReset(){
|
||||
this.message = this.dataProvider.message;
|
||||
this.deposit = this.dataProvider.deposit;
|
||||
this.enabled = this.dataProvider.enabled;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,8 +54,11 @@
|
|||
<span *ngIf="!item.officialname && !item.name">[no title available]</span>
|
||||
</span>
|
||||
</h6>
|
||||
<div *ngIf="item.deposit" class="uk-label uk-label-success">Deposit</div>
|
||||
<div *ngIf="item.deposit && item.message" class="">{{item.message}}</div>
|
||||
<div *ngIf="item.enabled" class="uk-label uk-text-primary uk-margin-small-right uk-padding-xsmall ">Content source</div>
|
||||
<div *ngIf="item.deposit" class="uk-label uk-label-success uk-padding-xsmall">Suggested for deposit</div>
|
||||
<div *ngIf="item.deposit && item.message" class=" uk-text-small uk-margin-top">
|
||||
<span class="uk-text-muted uk-text-xsmall">Deposit info:</span>
|
||||
{{item.message}}</div>
|
||||
<div *ngIf="item.selectioncriteria?.criteria?.length > 0" class="uk-margin-small-bottom uk-text-small">
|
||||
<div class="uk-text-meta uk-margin-small-bottom">Filters</div>
|
||||
<div [innerHTML]="criteriaUtils.getFiltersAsText(item.selectioncriteria.criteria)"></div>
|
||||
|
@ -67,33 +70,23 @@
|
|||
<div class="uk-card-footer uk-padding-remove-vertical">
|
||||
<div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
|
||||
<div>
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<a (click)="openDeposit(item)" class="uk-button uk-button-link uk-flex uk-flex-middle">
|
||||
<icon name="filters" [flex]="true"></icon>
|
||||
<span *ngIf="item.deposit" class="uk-margin-small-left"
|
||||
uk-tooltip="<div>Manage deposit info.</div>">
|
||||
|
||||
Edit deposit info
|
||||
</span>
|
||||
<span *ngIf="!(item.deposit)" class="uk-margin-small-left"
|
||||
uk-tooltip="<div>Add as a suggested repository to deposit.</div>">
|
||||
Add in deposit
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<a (click)="openCriteria(item)" class="uk-button uk-button-link uk-flex uk-flex-middle">
|
||||
<icon name="filters" [flex]="true"></icon>
|
||||
<span *ngIf="item.selectioncriteria?.criteria?.length > 0" class="uk-margin-small-left"
|
||||
<icon name="edit" [flex]="true"></icon>
|
||||
<!--<span *ngIf="item.selectioncriteria?.criteria?.length > 0" class="uk-margin-small-left"
|
||||
uk-tooltip="<div>Edit filters to limit research results.<br>Results which satisfy any of the selected filters will be included in your community.</div>">
|
||||
Edit filters
|
||||
</span>
|
||||
<span *ngIf="!(item.selectioncriteria?.criteria?.length > 0)" class="uk-margin-small-left"
|
||||
uk-tooltip="<div>Add filter to limit research results.<br>Results which satisfy any of the selected filters will be included in your community.</div>">
|
||||
Add filters
|
||||
</span>
|
||||
</span>-->
|
||||
<span class="uk-margin-small-left"
|
||||
uk-tooltip="<div>Select datasource as content source and/or suggest for deposit. Add filters to limit research results.<br>Results which satisfy any of the selected filters will be included in your community.</div>">
|
||||
Edit Options
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -49,8 +49,7 @@ export class RemoveContentProvidersComponent implements OnInit {
|
|||
public keyword: string = '';
|
||||
@Output() addContentProviders: EventEmitter<void> = new EventEmitter();
|
||||
@Output() editCriteria: EventEmitter<ContentProvider> = new EventEmitter<ContentProvider>();
|
||||
@Output() editDepositInfo: EventEmitter<ContentProvider> = new EventEmitter<ContentProvider>();
|
||||
|
||||
|
||||
constructor(private route: ActivatedRoute, private _router: Router,
|
||||
private _fb: UntypedFormBuilder,
|
||||
private _manageCommunityContentProvidersService: ManageCommunityContentProvidersService,
|
||||
|
@ -184,7 +183,5 @@ export class RemoveContentProvidersComponent implements OnInit {
|
|||
openCriteria(contentProvider: ContentProvider) {
|
||||
this.editCriteria.emit(contentProvider);
|
||||
}
|
||||
openDeposit(contentProvider: ContentProvider) {
|
||||
this.editDepositInfo.emit(contentProvider);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@ export class ManageCommunityContentProvidersService {
|
|||
return this.http.request('delete', url, {body: id, headers: headers});
|
||||
}
|
||||
|
||||
addContentProvider(properties: EnvProperties, pid: string, contentProvider: any): Observable<ContentProvider> {
|
||||
addContentProvider(properties: EnvProperties, pid: string, contentProvider: any, content:boolean, deposit:boolean): Observable<ContentProvider> {
|
||||
let url = properties.communityAPI + pid + '/datasources';
|
||||
let communityContentProvider = this.convertSearchContentProviderToCommunityContentProvider(contentProvider, pid);
|
||||
let communityContentProvider = this.convertSearchContentProviderToCommunityContentProvider(contentProvider, pid, content, deposit);
|
||||
return this.http.post<ContentProvider>(url, communityContentProvider);
|
||||
}
|
||||
|
||||
|
@ -26,12 +26,14 @@ export class ManageCommunityContentProvidersService {
|
|||
return this.http.post<ContentProvider>(url, contentProvider);
|
||||
}
|
||||
|
||||
convertSearchContentProviderToCommunityContentProvider(contentProvider: any, community: string): ContentProvider {
|
||||
convertSearchContentProviderToCommunityContentProvider(contentProvider: any, community: string, content:boolean, deposit:boolean): ContentProvider {
|
||||
let communityContentProvider: ContentProvider = new ContentProvider();
|
||||
communityContentProvider.communityId = community;
|
||||
communityContentProvider.officialname = contentProvider.title.name;
|
||||
communityContentProvider.name = contentProvider.englishname;
|
||||
communityContentProvider.openaireId = contentProvider.id;
|
||||
communityContentProvider.enabled = content;
|
||||
communityContentProvider.deposit = deposit;
|
||||
|
||||
return communityContentProvider;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue