Skip to content

Commit

Permalink
Version 4.16.2
Browse files Browse the repository at this point in the history
  • Loading branch information
acaurrinhos committed Jul 13, 2023
1 parent 9b14380 commit 96180c3
Show file tree
Hide file tree
Showing 17 changed files with 388 additions and 46 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Cyclos 4 UI",
"description": "The new Cyclos 4 frontend",
"icon": "cyclos.png",
"version": "4.16.1",
"version": "4.16.2",
"license": "MIT",
"author": {
"name": "Cyclos development team",
Expand Down
2 changes: 2 additions & 0 deletions src/app/shared/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,13 @@ export function validateBeforeSubmit(control: AbstractControl, returnNonValid =
control.controls.forEach(current => {
Array.prototype.push.apply(result, validateBeforeSubmit(current, true) as FormControl[]);
});
control.updateValueAndValidity({ onlySelf: true });
} else if (control instanceof FormGroup) {
Object.keys(control.controls).forEach(key => {
const current = control.controls[key];
Array.prototype.push.apply(result, validateBeforeSubmit(current, true) as FormControl[]);
});
control.updateValueAndValidity({ onlySelf: true });
}
const valid = empty(result);
if (!valid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
</ng-template>

<!-- To principal -->
<radio-group-field #toPrincipalType formControlName="toPrincipalType"
[label]="i18n.transaction.receiver">
<radio-group-field #toPrincipalType *ngIf="data.principalTypes.length > 1"
formControlName="toPrincipalType" [label]="i18n.transaction.receiver">
<field-option *ngFor="let pt of data.principalTypes" [value]="pt.id"
[text]="pt.name"></field-option>
</radio-group-field>
Expand Down
44 changes: 37 additions & 7 deletions src/app/ui/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { NextRequestState } from 'app/core/next-request-state';
import { ScriptLoaderService } from 'app/core/script-loader.service';
import { StateManager } from 'app/core/state-manager';
import { ApiHelper } from 'app/shared/api-helper';
import { apiUrl, empty, i18nRoot, initializeStyleLinks, isSameOrigin } from 'app/shared/helper';
import { apiUrl, empty, i18nRoot, initializeStyleLinks, isSameOrigin, setRootSpinnerVisible } from 'app/shared/helper';
import { BreadcrumbService } from 'app/ui/core/breadcrumb.service';
import { forkJoin, of, timer } from 'rxjs';
import { catchError, filter, first, switchMap } from 'rxjs/operators';
import { catchError, filter, first, map, switchMap } from 'rxjs/operators';

declare const UpUp: any;
declare const dataForFrontend: DataForFrontend;
Expand All @@ -35,6 +35,11 @@ export function initialize(
return async () => {
const apiRoot = apiUrl();

const themeLoaded$ = timer(1000, 500).pipe(filter(() => {
const style = getComputedStyle(document.body);
return !empty(style.getPropertyValue('--primary').trim());
}), first());

// Will split the session token if running on the same origin as the API
nextRequestState.useCookie = isSameOrigin(apiRoot);

Expand All @@ -53,7 +58,6 @@ export function initialize(
// Initialize the API configuration
apiConfig.rootUrl = apiRoot;


// Initialize the style links
initializeStyleLinks();

Expand Down Expand Up @@ -98,6 +102,36 @@ export function initialize(
}
return of(d);
});
dataForFrontendHolder.registerLoadHook(d => {
const theme = d.theme || {};
if (theme.id && theme.lastModifiedInMillis) {
const stylesLink = document.getElementById('stylesLink') as HTMLLinkElement;
const url = stylesLink?.href;
const marker = '/ui/theme.css';
const pos = url?.indexOf(marker);
if (pos > 0) {
const newUrl = `${url.substring(0, pos + marker.length)}?id=${theme.id}&mod=${theme.lastModifiedInMillis}&k=${d.dataForUi?.resourceCacheKey}`;
const root = document.querySelector('ui-root') as HTMLElement;
if (newUrl !== url && root) {
root.style.display = 'none';
root.classList.remove('d-flex');
setRootSpinnerVisible(true);
document.head.removeChild(stylesLink);
return timer(0).pipe(switchMap(() => {
stylesLink.href = newUrl;
document.head.appendChild(stylesLink);
return themeLoaded$.pipe(map(() => {
root.style.display = '';
root.classList.add('d-flex');
setRootSpinnerVisible(false);
return d;
}));
}));
}
}
}
return of(d);
});
if (environment.production && !environment.standalone) {
dataForFrontendHolder.registerLoadHook(d => {
return scriptLoader.loadScript('upup.min.js').pipe(
Expand All @@ -115,10 +149,6 @@ export function initialize(
});
}
const dataForFrontend$ = dataForFrontendHolder.initialize(dataForFrontend);
const themeLoaded$ = timer(1000, 500).pipe(filter(() => {
const style = getComputedStyle(document.body);
return !empty(style.getPropertyValue('--primary').trim());
}), first());


return forkJoin([dataForFrontend$, themeLoaded$]).toPromise();
Expand Down
6 changes: 4 additions & 2 deletions src/app/ui/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ export class LoginComponent
private get afterLogin(): () => any {
return () => {
setRootSpinnerVisible(false);
// Redirect to the correct URL
this.router.navigateByUrl(this.loginState.redirectUrl || '');
// Redirect to the correct URL if login confirmation isn't required
if (!this.dataForFrontendHolder.dataForUi?.auth?.loginConfirmation) {
this.router.navigateByUrl(this.loginState.redirectUrl || '');
}
};
}
}
8 changes: 3 additions & 5 deletions src/app/ui/marketplace/search/search-ads.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,14 @@
</custom-field-filter>
</div>
<div
*ngIf="marketplacePermissions.userSimple.view || marketplacePermissions.userWebshop.view"
*ngIf="marketplacePermissions.userSimple.view && marketplacePermissions.userWebshop.view"
class="col-12 col-md-6">
<single-selection-field formControlName="kind"
[label]="i18n.general.type"
[emptyOption]="i18n.general.notApplied">
<field-option *ngIf="marketplacePermissions.userSimple.view"
[text]="i18n.ad.type.simple" value="simple">
<field-option [text]="i18n.ad.type.simple" value="simple">
</field-option>
<field-option *ngIf="marketplacePermissions.userWebshop.view"
[text]="i18n.ad.type.webshop" value="webshop">
<field-option [text]="i18n.ad.type.webshop" value="webshop">
</field-option>
</single-selection-field>
</div>
Expand Down
21 changes: 15 additions & 6 deletions src/app/ui/operations/run-operation.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { ChangeDetectionStrategy, Component, Injector, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, Component, Injector, OnDestroy, OnInit } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { Params } from '@angular/router';
import {
Expand Down Expand Up @@ -35,7 +35,7 @@ import { debounceTime, first, tap } from 'rxjs/operators';
})
export class RunOperationComponent
extends BasePageComponent<OperationDataForRun>
implements OnInit {
implements OnInit, OnDestroy {

/** Cache keys to be used with the StateManager */
static OPERATION_DATA = 'operationData';
Expand Down Expand Up @@ -93,6 +93,7 @@ export class RunOperationComponent
const route = this.route.snapshot;
this.runScope = route.data.runScope;
this.userParam = route.params.user;
this.clearCloseTimer();

if (!this.runScope) {
throw new Error(`No runScope on ${route.url}`);
Expand Down Expand Up @@ -262,6 +263,17 @@ export class RunOperationComponent
}
}

ngOnDestroy(): void {
this.clearCloseTimer();
}

clearCloseTimer() {
if (this.closeTimer) {
clearTimeout(this.closeTimer);
this.closeTimer = null;
}
}

cleanCache() {
this.stateManager.delete(RunOperationComponent.OPERATION_DATA);
this.stateManager.delete(RunOperationComponent.OPERATION_RESULT_RESPONSE);
Expand Down Expand Up @@ -406,10 +418,7 @@ export class RunOperationComponent
}

reload() {
if (this.closeTimer) {
clearTimeout(this.closeTimer);
this.closeTimer = null;
}
this.clearCloseTimer();
this.runOperationHelper.startNewOperation = true;
super.reload();
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/records/search-records.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</ng-container>
<ng-container *ngIf="this.generalSearch || !isOwnRecords()">
<div class="col-12 col-md-6">
<user-field formControlName="createdBy"
<user-field formControlName="createdBy" [allowSelf]="true"
[label]="i18n.record.createdBy"></user-field>
</div>
<!-- Force a new line to keep date range in same row -->
Expand Down
4 changes: 2 additions & 2 deletions src/app/ui/records/search-records.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class SearchRecordsComponent
headingActions.push(new HeadingAction(SvgIcon.PlusCircle, this.i18n.general.addNew, () =>
this.router.navigate(['/records', this.param, this.type, 'new']), true));
}
this.exportHelper.headingActions(data.exportFormats,
const exportActions = this.exportHelper.headingActions(data.exportFormats,
f => {
const params = {
format: f.internalName,
Expand All @@ -102,7 +102,7 @@ export class SearchRecordsComponent
return this.recordsService.exportOwnerRecords$Response(params);
}
});
this.headingActions = headingActions;
this.headingActions = [...headingActions, ...exportActions];
}

showKeywords(): boolean {
Expand Down
4 changes: 2 additions & 2 deletions src/app/ui/shared/agreement-content-dialog.component.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<ng-container *ngIf="content$ | async as content; else loading">
<div #content>
<div #contentDiv>
<h1>
{{ agreement.name }}
</h1>
<div class="mb-3" [innerHTML]="content | trust"></div>
</div>
<actions forceRow>
<action-button (action)="print(content, printOutput)"
<action-button (action)="print(contentDiv, printOutput)"
[label]="i18n.general.print">
</action-button>
<action-button outline (action)="modalRef.hide()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
[headingActions]="headingActions$ | async">
<div [formGroup]="form" class="filters-form filters-form-separator">
<div class="row">
<div class="col-12 col-md-6">
<input-field formControlName="keywords"
[label]="i18n.general.keywords"></input-field>
</div>
<div class="col-12 col-md-6" *ngIf="!self">
<label-value [label]="i18n.general.user" kind="fieldView">
<user-link [user]="data.user"></user-link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class SearchUserOperatorsComponent
}

protected getFormControlNames() {
return ['operatorGroups', 'statuses', 'creationBegin', 'creationEnd'];
return ['keywords', 'operatorGroups', 'statuses', 'creationBegin', 'creationEnd'];
}

ngOnInit() {
Expand Down
Loading

0 comments on commit 96180c3

Please sign in to comment.