ts component import { Component, OnInit } from "@angular/core"; import { OrganisationService } from "../organisation.service.ts"; import { UserService } from "../../user/user.service.ts"; import { ng1RootScope } from "../../ajs-upgraded-providers/rootScope.ts"; @Component({ selector: 'app-dropdown-organisation-list.component', templateUrl: 'assets/components/organisation/dropdown-organisation-list/dropdown-organisation-list.component.html', }) export class DropdownOrganisationListComponent implements OnInit { organisations = []; showDropdown = false; constructor( private organisationService: OrganisationService, private userService: UserService, private rootScope: ng1RootScope, ) {} ngOnInit() { this.userService.getOrganisation().then(() => { this.prepareDataForView(); }); document.body.addEventListener('click', this.closeDropdown.bind(this)); document.body.addEventListener('touchstart', this.closeDropdown.bind(this)); this.rootScope.on('reloadOrganisationList', () => { this.prepareDataForView(); }); } closeDropdown(event) { if (!(event.target).parents('dropdown-organisation-list').length) { this.showDropdown = false; } } toggleDropdown() { this.showDropdown = !this.showDropdown; } loginIntoOrganisation(orgId) { const userPermissions = this.userService.getPermissions(); let isLoginFromTempOrg = false; Object.keys(userPermissions).map(permission => { if (permission === 'temp.organisation' || permission === 'temp.agent') { isLoginFromTempOrg = true; } }); const redirectUrl = isLoginFromTempOrg ? '/organisation' : null; this.organisationService.loginIntoOrganisation(orgId, redirectUrl); } private prepareDataForView() { Promise.all([ this.organisationService.getOrganisationList(), this.organisationService.getUserGroupsInAllOrganisations(), ]) .then(response => { this.organisations = response[0].data .filter(organisation => { const isCurrentOrg = organisation.id === organisation.id; if (!organisation.isTempOrg && !isCurrentOrg) { return organisation; } }) .map(organisation => { organisation.groups = []; const userOrganisationsGroups = response[1].data; for (let i = 0; i < userOrganisationsGroups.length; i++) { if (userOrganisationsGroups[i].orgId === organisation.id) { organisation.groups.push(userOrganisationsGroups[i].title); } } return organisation; }); }) } } modul 'use strict'; import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {FormsModule} from "@angular/forms"; import {downgradeComponent} from "@angular/upgrade/static"; import OrganisationContractsModule from './contracts/contracts.module'; import TerminateContractModule from './terminate-contract/terminate.module'; import {TransferAgreementModule, TransferAgreementModuleNg1} from './transferagreement/transfer-agreement.module.ts'; import {TaxpayerCommonModule} from "../taxpayer-common/taxpayer-common.module.ts"; import OrganisationService from './organisation.service.ts'; import {OrganisationListComponent} from './organisation-list/organisation-list.component.ts'; import {OrganisationsPageComponent} from './organisations-page/organisations-page.component.ts'; import { DropdownOrganisationListComponent } from './dropdown-organisation-list/dropdown-organisation-list.component.ts'; import {OrganisationEditPageComponent} from "./organisation-edit-page/organisation-edit-page.component.ts"; import {OrganisationFormComponent} from "./organisation-edit-page/organisation-form/organisation-form.component.ts"; import {EntrepreneurFormComponent} from "./organisation-edit-page/entrepreneur-form/entrepreneur-form.component.ts"; import {ReturnUserPageComponent} from "./terminate-contract/return-user/return-user.component.ts"; const OrganisationModuleNg1 = angular .module('taxpayer.components.organisation', [ OrganisationContractsModule, TerminateContractModule, TransferAgreementModuleNg1, ]) .service('OrganisationService', OrganisationService) .directive('appOrganisationsPage', downgradeComponent({component: OrganisationsPageComponent}) as angular.IDirectiveFactory) .directive('appOrganisationEditPage', downgradeComponent({component: OrganisationEditPageComponent}) as angular.IDirectiveFactory) .directive ('appDropdownOrganisationList', downgradeComponent({component: DropdownOrganisationListComponent}) as angular.IDirectiveFactory) .directive('appReturnUserPage', downgradeComponent({component: ReturnUserPageComponent}) as angular.IDirectiveFactory) .config(['$routeProvider', function ($routeProvider) { $routeProvider .when('/organisation', { template: '<app-organisations-page></app-organisations-page>', }) .when('/organisation/edit', { template: '<app-organisation-edit-page></app-organisation-edit-page>', }) .when('/organisation/new-org/main-info', { template: '<org-registration-main-info environment="\'cabinet\'"></org-registration-main-info>', }) .when('/return-user', { template: '<app-return-user-page></app-return-user-page>', }) }]) .name; @NgModule({ imports: [ CommonModule, TransferAgreementModule, TaxpayerCommonModule, FormsModule, ], declarations: [ OrganisationListComponent, OrganisationsPageComponent, OrganisationEditPageComponent, OrganisationFormComponent, EntrepreneurFormComponent, ReturnUserPageComponent, DropdownOrganisationListComponent, ], providers: [], entryComponents: [ OrganisationsPageComponent, OrganisationEditPageComponent, ReturnUserPageComponent, ], }) class OrganisationModule { } export {OrganisationModuleNg1, OrganisationModule} - And what do you want? Would you like us to analyze your entire listing? Could at least fill in the online sandbox ... - iluxa1810
- @Artem I don’t understand where the connection between angularjs and angular is and what you are trying to do, and why is this bike with hybridity at all - overthesanity
- @overthesanity is an old project, it has to be rewritten to a new angular. I do not understand the error, and I don’t imagine how to solve it. - Artem
- @Artem so how do you think someone can figure out what you brought in 1 heap? :) - overthesanity
|