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
|
||||
_links: {
|
||||
self: HALLink;
|
||||
ePerson: HALLink;
|
||||
dSpaceObject: HALLink;
|
||||
eperson: HALLink;
|
||||
resource: HALLink;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -48,14 +48,14 @@ export class Subscription extends DSpaceObject {
|
||||
* Will be undefined unless the logo {@link HALLink} has been resolved.
|
||||
*/
|
||||
@link(EPERSON)
|
||||
ePerson?: Observable<RemoteData<EPerson>>;
|
||||
eperson?: Observable<RemoteData<EPerson>>;
|
||||
|
||||
/**
|
||||
* The logo for this Community
|
||||
* Will be undefined unless the logo {@link HALLink} has been resolved.
|
||||
*/
|
||||
@link(DSPACE_OBJECT)
|
||||
dSpaceObject?: Observable<RemoteData<DSpaceObject>>;
|
||||
resource?: Observable<RemoteData<DSpaceObject>>;
|
||||
/**
|
||||
* The embedded ePerson & dSpaceObject for this Subscription
|
||||
*/
|
||||
|
@@ -30,7 +30,7 @@
|
||||
(click)="activeModal.close()">
|
||||
{{'item.page.subscriptions.modal.close' | translate}}
|
||||
</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)">
|
||||
<i class='fas fa-circle-notch fa-spin'></i> {{'item.page.subscriptions.modal.new-subscription-form.processing' | translate}}
|
||||
</span>
|
||||
|
@@ -66,6 +66,10 @@ export class SubscriptionModalComponent implements OnInit {
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@@ -98,6 +102,14 @@ export class SubscriptionModalComponent implements OnInit {
|
||||
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 {
|
||||
|
@@ -143,7 +143,7 @@ export class SubscriptionsDataService extends IdentifiableDataService<Subscripti
|
||||
* @param options options for the find all request
|
||||
*/
|
||||
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(
|
||||
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>
|
||||
<tbody>
|
||||
<tr ds-subscription-view *ngFor="let subscription of subscriptions?.page"
|
||||
[dso]="(subscription?.dSpaceObject | async)?.payload"
|
||||
[eperson]="(subscription?.ePerson | async)?.payload?.id"
|
||||
[dso]="(subscription?.resource | async)?.payload"
|
||||
[eperson]="(subscription?.eperson | async)?.payload?.id"
|
||||
[subscription]="subscription"
|
||||
(reload)="refresh()">
|
||||
</tr>
|
||||
|
Reference in New Issue
Block a user