mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-08-29 07:50:08 +08:00
Move classic-view component to views
- Move view, as it is used by the router as a view - Move classic-view specific services - Remove api.classic-view.get.ts and classic-view.facade.ts -- Deprecated -- The approach of getting the html from the api wasn't followed
This commit is contained in:
parent
d1534850fb
commit
c79fae5473
11 changed files with 8 additions and 130 deletions
|
@ -8,8 +8,8 @@ import {RecordComponent} from '@views/record/components/record-view/record.compo
|
|||
import {BaseRecordResolver} from '@services/metadata/base-record.resolver';
|
||||
import {LoginAuthGuard} from '@services/auth/login-auth-guard.service';
|
||||
import {BaseMetadataResolver} from '@services/metadata/base-metadata.resolver';
|
||||
import {ClassicViewUiComponent} from '@components/classic-view/classic-view.component';
|
||||
import {ClassicViewResolver} from '@services/classic-view/classic-view.resolver';
|
||||
import {ClassicViewUiComponent} from '@views/classic/components/classic-view/classic-view.component';
|
||||
import {ClassicViewResolver} from '@views/classic/services/classic-view.resolver';
|
||||
|
||||
@Injectable()
|
||||
export class AppInit {
|
||||
|
|
|
@ -13,7 +13,7 @@ import {AppComponent} from './app.component';
|
|||
|
||||
import {NavbarUiModule} from '@components/navbar/navbar.module';
|
||||
import {FooterUiModule} from '@components/footer/footer.module';
|
||||
import {ClassicViewUiModule} from '@components/classic-view/classic-view.module';
|
||||
import {ClassicViewUiModule} from '@views/classic/components/classic-view/classic-view.module';
|
||||
import {MessageUiModule} from '@components/message/message.module';
|
||||
import {FilterUiModule} from '@components/filter/filter.module';
|
||||
import {ColumnChooserModule} from '@components/columnchooser/columnchooser.module';
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Apollo} from 'apollo-angular';
|
||||
import gql from 'graphql-tag';
|
||||
import {Observable} from 'rxjs';
|
||||
import {ApolloQueryResult} from '@apollo/client/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ClassicViewGQL {
|
||||
|
||||
constructor(private apollo: Apollo) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch data either from backend
|
||||
*
|
||||
* @param module to get from
|
||||
* @param id of the record
|
||||
* @param params
|
||||
* @param metadata with the fields to ask for
|
||||
*/
|
||||
public fetch(module: string,
|
||||
params: { [key: string]: string },
|
||||
metadata: { fields: string[] }): Observable<ApolloQueryResult<any>> {
|
||||
|
||||
const fields = metadata.fields;
|
||||
|
||||
const queryOptions = {
|
||||
query: gql`
|
||||
query getClassicView($module: String!, $params: Iterable) {
|
||||
getClassicView(module:$module, params:$params) {
|
||||
${fields.join('\n')}
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
module,
|
||||
params
|
||||
},
|
||||
};
|
||||
|
||||
return this.apollo.query(queryOptions);
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import {map} from 'rxjs/operators';
|
||||
|
||||
import {ClassicViewGQL} from './api.classic-view.get';
|
||||
|
||||
export interface ClassicView {
|
||||
id: string;
|
||||
_id: string;
|
||||
action: string;
|
||||
record: string;
|
||||
html: string;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ClassicViewStore {
|
||||
|
||||
protected fieldsMetadata = {
|
||||
fields: [
|
||||
'id',
|
||||
'_id',
|
||||
'action',
|
||||
'record',
|
||||
'html'
|
||||
]
|
||||
};
|
||||
|
||||
constructor(private classicViewGQL: ClassicViewGQL) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Public Api
|
||||
*/
|
||||
|
||||
/**
|
||||
* Load ClassicView from the backend.
|
||||
* Returns observable to be used in resolver if needed
|
||||
*
|
||||
* @returns Observable<any>
|
||||
*/
|
||||
public load($module: string, $params: { [key: string]: string }): Observable<any> {
|
||||
return this.fetch($module, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal API
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Fetch the classic view from the backend
|
||||
*
|
||||
* @returns Observable<any>
|
||||
*/
|
||||
protected fetch($module: string, $params: { [key: string]: string }): Observable<ClassicView> {
|
||||
|
||||
return this.classicViewGQL.fetch($module, $params, this.fieldsMetadata)
|
||||
.pipe(map(({data}) => {
|
||||
const classicView: ClassicView = {
|
||||
id: null,
|
||||
_id: null,
|
||||
action: null,
|
||||
record: null,
|
||||
html: null,
|
||||
};
|
||||
|
||||
if (data.getClassicView) {
|
||||
return data.getClassicView;
|
||||
}
|
||||
|
||||
return classicView;
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
|
@ -5,8 +5,8 @@ import {RouterTestingModule} from '@angular/router/testing';
|
|||
import {ClassicViewUiComponent} from './classic-view.component';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {ApolloTestingModule} from 'apollo-angular/testing';
|
||||
import {IframePageChangeObserver} from '@services/classic-view/iframe-page-change-observer.service';
|
||||
import {IframeResizeHandlerHandler} from '@services/classic-view/iframe-resize-handler.service';
|
||||
import {IframePageChangeObserver} from '@views/classic/services/iframe-page-change-observer.service';
|
||||
import {IframeResizeHandlerHandler} from '@views/classic/services/iframe-resize-handler.service';
|
||||
import {AuthService} from '@services/auth/auth.service';
|
||||
|
||||
class ClassicViewUiComponentMock extends ClassicViewUiComponent {
|
|
@ -2,8 +2,8 @@ import {AfterViewInit, Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChi
|
|||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {DomSanitizer} from '@angular/platform-browser';
|
||||
import {RouteConverter, RouteInfo} from '@services/navigation/route-converter/route-converter.service';
|
||||
import {IframePageChangeObserver} from '@services/classic-view/iframe-page-change-observer.service';
|
||||
import {IframeResizeHandlerHandler} from '@services/classic-view/iframe-resize-handler.service';
|
||||
import {IframePageChangeObserver} from '@views/classic/services/iframe-page-change-observer.service';
|
||||
import {IframeResizeHandlerHandler} from '@views/classic/services/iframe-resize-handler.service';
|
||||
import {AuthService} from '@services/auth/auth.service';
|
||||
import {SystemConfigStore} from '@store/system-config/system-config.store';
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {AppManagerModule} from '../../app-manager/app-manager.module';
|
||||
import {AppManagerModule} from '@base/app-manager/app-manager.module';
|
||||
import {ClassicViewUiComponent} from './classic-view.component';
|
||||
|
||||
@NgModule({
|
Loading…
Add table
Add a link
Reference in a new issue