mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
[CST-7757] Response parameters fixed; submit button disabled if frequency is missing
This commit is contained in:
@@ -39,8 +39,8 @@ export class Subscription extends DSpaceObject {
|
|||||||
@deserialize
|
@deserialize
|
||||||
_links: {
|
_links: {
|
||||||
self: HALLink;
|
self: HALLink;
|
||||||
ePerson: HALLink;
|
eperson: HALLink;
|
||||||
dSpaceObject: HALLink;
|
resource: HALLink;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,14 +48,14 @@ export class Subscription extends DSpaceObject {
|
|||||||
* Will be undefined unless the logo {@link HALLink} has been resolved.
|
* Will be undefined unless the logo {@link HALLink} has been resolved.
|
||||||
*/
|
*/
|
||||||
@link(EPERSON)
|
@link(EPERSON)
|
||||||
ePerson?: Observable<RemoteData<EPerson>>;
|
eperson?: Observable<RemoteData<EPerson>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The logo for this Community
|
* The logo for this Community
|
||||||
* Will be undefined unless the logo {@link HALLink} has been resolved.
|
* Will be undefined unless the logo {@link HALLink} has been resolved.
|
||||||
*/
|
*/
|
||||||
@link(DSPACE_OBJECT)
|
@link(DSPACE_OBJECT)
|
||||||
dSpaceObject?: Observable<RemoteData<DSpaceObject>>;
|
resource?: Observable<RemoteData<DSpaceObject>>;
|
||||||
/**
|
/**
|
||||||
* The embedded ePerson & dSpaceObject for this Subscription
|
* The embedded ePerson & dSpaceObject for this Subscription
|
||||||
*/
|
*/
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
(click)="activeModal.close()">
|
(click)="activeModal.close()">
|
||||||
{{'item.page.subscriptions.modal.close' | translate}}
|
{{'item.page.subscriptions.modal.close' | translate}}
|
||||||
</button>
|
</button>
|
||||||
<button type="submit" class="btn btn-success" [disabled]="(processing$ | async)">
|
<button type="submit" class="btn btn-success" [disabled]="(processing$ | async) || !isValid">
|
||||||
<span *ngIf="(processing$ | async)">
|
<span *ngIf="(processing$ | async)">
|
||||||
<i class='fas fa-circle-notch fa-spin'></i> {{'item.page.subscriptions.modal.new-subscription-form.processing' | translate}}
|
<i class='fas fa-circle-notch fa-spin'></i> {{'item.page.subscriptions.modal.new-subscription-form.processing' | translate}}
|
||||||
</span>
|
</span>
|
||||||
|
@@ -66,6 +66,10 @@ export class SubscriptionModalComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
private frequencyDefaultValues = ['D', 'M', 'W'];
|
private frequencyDefaultValues = ['D', 'M', 'W'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if form status has changed and at least one frequency is checked
|
||||||
|
*/
|
||||||
|
isValid = false;
|
||||||
/**
|
/**
|
||||||
* Event emitted when a given subscription has been updated
|
* Event emitted when a given subscription has been updated
|
||||||
*/
|
*/
|
||||||
@@ -98,6 +102,14 @@ export class SubscriptionModalComponent implements OnInit {
|
|||||||
this.initFormByAllSubscriptions();
|
this.initFormByAllSubscriptions();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.subscriptionForm.valueChanges.subscribe((newValue) => {
|
||||||
|
let anyFrequencySelected = false;
|
||||||
|
for (let f of this.frequencyDefaultValues) {
|
||||||
|
anyFrequencySelected = anyFrequencySelected || newValue.content.frequencies[f];
|
||||||
|
}
|
||||||
|
this.isValid = anyFrequencySelected;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private initFormByAllSubscriptions(): void {
|
private initFormByAllSubscriptions(): void {
|
||||||
|
@@ -143,7 +143,7 @@ export class SubscriptionsDataService extends IdentifiableDataService<Subscripti
|
|||||||
* @param options options for the find all request
|
* @param options options for the find all request
|
||||||
*/
|
*/
|
||||||
findAllSubscriptions(options?): Observable<RemoteData<PaginatedList<Subscription>>> {
|
findAllSubscriptions(options?): Observable<RemoteData<PaginatedList<Subscription>>> {
|
||||||
return this.findAllData.findAll(options, true, true, followLink('dSpaceObject'), followLink('ePerson'));
|
return this.findAllData.findAll(options, true, true, followLink('resource'), followLink('eperson'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ export class SubscriptionsDataService extends IdentifiableDataService<Subscripti
|
|||||||
|
|
||||||
return this.getEndpoint().pipe(
|
return this.getEndpoint().pipe(
|
||||||
map(href => `${href}/search/${this.findByEpersonLinkPath}`),
|
map(href => `${href}/search/${this.findByEpersonLinkPath}`),
|
||||||
switchMap(href => this.findListByHref(href, optionsWithObject, true, true, followLink('dSpaceObject'), followLink('ePerson')))
|
switchMap(href => this.findListByHref(href, optionsWithObject, false, true, followLink('resource'), followLink('eperson')))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -24,8 +24,8 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ds-subscription-view *ngFor="let subscription of subscriptions?.page"
|
<tr ds-subscription-view *ngFor="let subscription of subscriptions?.page"
|
||||||
[dso]="(subscription?.dSpaceObject | async)?.payload"
|
[dso]="(subscription?.resource | async)?.payload"
|
||||||
[eperson]="(subscription?.ePerson | async)?.payload?.id"
|
[eperson]="(subscription?.eperson | async)?.payload?.id"
|
||||||
[subscription]="subscription"
|
[subscription]="subscription"
|
||||||
(reload)="refresh()">
|
(reload)="refresh()">
|
||||||
</tr>
|
</tr>
|
||||||
|
Reference in New Issue
Block a user