File

src/app/modules/profile/rup/rup.ts

Description

Просмотр РУПа (Рабочий учебный план) обучающегося

Implements

OnInit

Metadata

selector profile-rup
styleUrls rup.scss
templateUrl ./rup.html

Index

Properties
Methods

Constructor

constructor(commonService: CommonService, settingsService: SettingsService)

Конструктор

Parameters :
Name Type Description
commonService CommonService
settingsService SettingsService

Methods

getData
getData()

Получение данных

Returns : void
getOptions
getOptions()

Получение настроек

Returns : void
ngOnInit
ngOnInit()

Получение данных и настроек

Returns : void
onSave
onSave(event: )

Сохранение выбранных дисциплин

Parameters :
Name Type Description
event
Returns : void

Properties

allowSelection
allowSelection: boolean
Type : boolean
Default value : false

Разрешить выбор дисциплин, если выбор еще не сделан

header
header: string
Type : string
Default value : Рабочий план

Заголовок

loading
loading: boolean
Type : boolean

Индикатор загрузки основных данных

options
options: any
Type : any

Настройки

rups
rups: any
Type : any

РУП

import { Component, OnInit } from '@angular/core';
import { CommonService } from 'glx.ui/components/kernel/services/common.service';
import { SettingsService } from 'glx.ui/components/kernel/services/settings.service';

/**
 * Просмотр РУПа (Рабочий учебный план) обучающегося
 */
@Component({
  selector: 'profile-rup',
  templateUrl: './rup.html',
  styleUrls: ['./rup.scss']
})
export class ProfileRupComponent implements OnInit {
  /**
   * Заголовок
   * @type {string}
   */
  header: string = 'Рабочий план';
  /**
   * Разрешить выбор дисциплин, если выбор еще не сделан
   * @type {boolean}
   */
  allowSelection: boolean = false;
  /**
   * РУП
   */
  rups: any;
  /**
   * Настройки
   */
  options: any;
  /**
   * Индикатор загрузки основных данных
   * @type {boolean}
   */
  loading: boolean;

  /**
   * Конструктор
   * @param {CommonService} commonService
   * @param {SettingsService} settingsService
   */
  constructor(private commonService: CommonService, private settingsService: SettingsService) {
  }

  /**
   * Получение данных и настроек
   */
  ngOnInit() {
    this.getOptions();
    this.getData();
  }

  /**
   * Получение настроек
   */
  getOptions() {
    this.settingsService.getSection('rup')
      .subscribe(
        data => {
          this.options = data.rupOptions;
          this.header = data.rupOptions.header;
          this.allowSelection = data.allowRupSelection;
        },
        error => {
          console.error(error);
        });
  }

  /**
   * Получение данных
   */
  getData() {
    let loaderTimeout = setTimeout(() => {
      this.loading = true;
    }, 200);

    this.commonService.get('rups')
      .subscribe(
        data => {
          if (typeof data === 'object') {
            this.rups = data;
          } else {
            this.rups = {
              sections: []
            };
          }
        },
        error => {
          console.error(error);
        },
        () => {
          clearTimeout(loaderTimeout);
          this.loading = false;
        });

    setTimeout(() => {
      clearTimeout(loaderTimeout);
      this.loading = false;
    }, 10000);
  }

  /**
   * Сохранение выбранных дисциплин
   * @param event
   */
  onSave(event) {
    let data = {
      id: this.rups.id,
      profile_id: this.rups.pivot.profile_id || 0,
      selection: event.selection
    };

    this.commonService.post('rups', data).subscribe(
      data => {
        this.commonService.clearCache('rups');
        this.getData();
      },
      error => {
        console.error(error);
      });
  }
}
<glx-page-title-bx [header]="header"></glx-page-title-bx>
<div class="rup-wrapper">
  <glx-loading-banner
    [loading]="loading"
    [svg]="true"
    text="Подождите, идет загрузка..."
  ></glx-loading-banner>

  <glx-rup-viewer
    *ngIf="!loading && rups && options"
    [data]="rups"
    (onSave)="onSave($event)"
    [options]="options"
    [allowSelection]="allowSelection"
  ></glx-rup-viewer>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""