当有多个站点的单个内容目录时,SmartEdit 无法加载正确的站点

如何解决当有多个站点的单个内容目录时,SmartEdit 无法加载正确的站点

在我当前的项目中,我们有多个站点和单个内容目录。 例如。 目录:abcContentCatalog 站点:usSite、europeSite、africaSite。 所有网站都有不同的登录页面

所有这些站点都连接到一个目录,即 abcContentCatalog。

现在,当我打开 SmartEdit 并选择任何站点时,SmartEdit 会选择它从列表中获得的最后一个站点

在浏览器控制台中收到此警告消息:“为内容目录找到了许多站点”。

经过 SmartEdit 源代码后,我发现 CatalogService.ts 文件具有 getDefaultSiteForContentCatalog 方法

getDefaultSiteForContentCatalog(contentCatalogId: string): Promise<ISite> {
    return ((this.siteService.getSites() as unkNown) as Promise<ISite[]>).then((sites) => {
        const defaultSitesForCatalog = sites.filter((site) => {
            // ContentCatalogs in the site object are sorted. The last one is considered
            // the default one for a given site.
            const siteDefaultContentCatalog = lodash.last(site.contentCatalogs);
            return siteDefaultContentCatalog && siteDefaultContentCatalog === contentCatalogId;
        });

        if (defaultSitesForCatalog.length === 0) {
            this.logService.warn(
                `[catalogService] - No default site found for content catalog ${contentCatalogId}`
            );
        } else if (defaultSitesForCatalog.length > 1) {
            this.logService.warn(
                `[catalogService] - Many default sites found for content catalog ${contentCatalogId}`
            );
        }

        return defaultSitesForCatalog[0];
    });
}

我在自定义 smartEdit 扩展中覆盖了 Service 方法,但我需要知道如何覆盖调用此服务的 OOTB Angular 组件 LandingPageComponent

我使用了 https://launchpad.support.sap.com/#/notes/2805883 提供的解决方案 但是在覆盖 LandaingPageComponent 之后,它并没有被调用,而是一直在调用 OOTB。

PfizerLandingPageComponent

/*
 * copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved.
 */
import * as angular from 'angular';
import { PfizerCatalogService } from 'pfizerprimesmarteditcontainer/PfizerCatalogService';
import { PfizerSiteService } from 'pfizerprimesmarteditcontainer/PfizerSiteService';
import {
    GenericEditorField,IBaseCatalog,ISeComponent,ISeDropdownSelectedOption,ISeDropdownSelectedOptionEventData,IStorageService,SeComponent,SystemEventService,TypedMap
} from 'smarteditcommons';


interface ISelectedSite extends ISeDropdownSelectedOption {
    uid: string;
    contentCatalogs: string[];
    name: TypedMap<string>;
    previewUrl: string;
}

/**
 * @ngdoc overview
 * @name PfizerLandingPageComponent
 * @description
 *
 * Component responsible of displaying the SmartEdit landing page.
 *
 */
@SeComponent({
    templateUrl: 'PfizerLandingPageTemplate.html'
})
export class PfizerLandingPageComponent implements ISeComponent {
    public sitesId: string = 'sites-id';
    public catalogs: IBaseCatalog[];
    public qualifier: string;
    public field: Partial<GenericEditorField>;
    public model: { site: string };
    private unregisterSitesDropdownEventHandler: () => void;
    private SELECTED_SITE_COOKIE_NAME = 'seselectedsite';

    constructor(
        private siteService: PfizerSiteService,private catalogService: PfizerCatalogService,private systemEventService: SystemEventService,private storageService: IStorageService,private SITES_RESOURCE_URI: string,private LINKED_DROPDOWN: string
    ) {}

    $onInit() {
        this.catalogs = [];
        this.qualifier = 'site';
        this.field = {
            uri: this.SITES_RESOURCE_URI,idAttribute: 'uid',labelAttributes: ['name'],editable: true,paged: false
        };

        this.siteService.getSelectedSiteUid().then((siteId: string) => (this.model = { site: siteId }));

        this.removeStorefrontCssClass();

        this.unregisterSitesDropdownEventHandler = this.systemEventService.subscribe(
            this.sitesId + this.LINKED_DROPDOWN,this.selectedSiteDropdownEventHandler.bind(this)
        );
    }

    $onDestroy() {
        this.unregisterSitesDropdownEventHandler();
    }


    private removeStorefrontCssClass(): void {
        const bodyTag = angular.element(document.querySelector('body'));
        if (bodyTag.hasClass('is-storefront')) {
            bodyTag.removeClass('is-storefront');
        }
    }

    private selectedSiteDropdownEventHandler(
        eventId: string,data: ISeDropdownSelectedOptionEventData<ISelectedSite>
    ): void {
        if (data.optionObject) {
            const siteId = data.optionObject.id;
            this.setSelectedSite(siteId);
            this.loadCatalogsBySite(siteId);
        } else {
            this.catalogs = [];
        }
    }

    private setSelectedSite(siteId: string): void {
        this.storageService.setValueInLocalStorage(this.SELECTED_SITE_COOKIE_NAME,siteId,false);
    }

    private loadCatalogsBySite(siteId: string): void {
        this.catalogService
            .getContentCatalogsForSite(siteId)
            .then((catalogs: IBaseCatalog[]) => (this.catalogs = catalogs));
    }
}

覆盖 SeRouteService 路由以使用我的组件

legacypfizerprimesmarteditcontainer.ts

/*
 * copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved.
 */
import { doImport } from './forcedImports';
doImport();
import {IFeatureService,SeModule,SeRouteService } from 'smarteditcommons';
import { PfizerLandingPageComponent } from './pfizerLandingPage/PfizerLandingPageComponent';
/**
 * @ngdoc overview
 * @name pfizerprimesmarteditContainer
 * @description
 * Placeholder for documentation
 */


@SeModule({
    declarations: [PfizerLandingPageComponent],imports: ['smarteditServicesModule','abAnalyticsToolbarItemmodule'],initialize: (featureService: IFeatureService) => {
        'ngInject';
        ////////////////////////////////////////////////////
        // Create Toolbar Item
        ////////////////////////////////////////////////////
        // Create the toolbar item as a feature.
        featureService.addToolbarItem({
            toolbarId: 'smartEditPerspectivetoolbar',key: 'abAnalyticsToolbarItem',type: 'HYBRID_ACTION',nameI18nKey: 'ab.analytics.toolbar.item.name',priority: 2,section: 'left',iconClassName: 'icon-message-information se-toolbar-menu-ddlb--button__icon',include: 'abAnalyticsToolbarItemWrapperTemplate.html'
        });
        
    },config: (
        $provide: angular.auto.IProvideService,LANDING_PAGE_PATH: string,$routeProvider: angular.route.IRouteProvider
    ) => {
        'ngInject';
        SeRouteService.init($routeProvider);
        SeRouteService.provideLegacyRoute({
            path: '/',route: {
                template: '<landing-page></landing-page>'
            }
        });

        /*SeRouteService.provideLegacyRoute({
            path: LANDING_PAGE_PATH + 'sites/:siteId',route: {
                template: '<landing-page></landing-page>'
            }
        });*/
    }
})
export class PfizerprimesmarteditContainer {}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?