<commit_before>import {
  AfterViewInit,
  ChangeDetectorRef,
  Component,
  ElementRef,
  EventEmitter,
  Injector,
  NgZone,
  OnDestroy,
  OnInit,
  ViewChild,
  ViewEncapsulation,
} from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { ActivatedRoute, Router, UrlSegment } from '@angular/router';
import { BehaviorSubject, combineLatest, Observable, Subscription } from 'rxjs';

import { InputConverter } from '../../decorators/input-converter';
import { IComponent } from '../../interfaces/component.interface';
import { IFormDataComponent } from '../../interfaces/form-data-component.interface';
import { IFormDataTypeComponent } from '../../interfaces/form-data-type-component.interface';
import { ServiceResponse } from '../../interfaces/service-response.interface';
import { OFormLayoutManagerComponent } from '../../layouts/form-layout/o-form-layout-manager.component';
import { OntimizeServiceProvider } from '../../services/data-service.provider';
import { DialogService } from '../../services/dialog.service';
import { NavigationService, ONavigationItem } from '../../services/navigation.service';
import { OntimizeService } from '../../services/ontimize/ontimize.service';
import { PermissionsService } from '../../services/permissions/permissions.service';
import { SnackBarService } from '../../services/snackbar.service';
import { FormValueOptions } from '../../types/form-value-options.type';
import { OFormInitializationOptions } from '../../types/o-form-initialization-options.type';
import { OFormPermissions } from '../../types/o-form-permissions.type';
import { OPermissions } from '../../types/o-permissions.type';
import { Codes } from '../../util/codes';
import { SQLTypes } from '../../util/sqltypes';
import { Util } from '../../util/util';
import { OFormContainerComponent } from '../form-container/o-form-container.component';
import { OFormControl } from '../input/o-form-control.class';
import { OFormCacheClass } from './cache/o-form.cache.class';
import { CanComponentDeactivate, CanDeactivateFormGuard } from './guards/o-form-can-deactivate.guard';
import { OFormNavigationClass } from './navigation/o-form.navigation.class';
import { OFormValue } from './OFormValue';
import { OFormToolbarComponent } from './toolbar/o-form-toolbar.component';

interface IFormDataComponentHash {
  [attr: string]: IFormDataComponent;
}

export const DEFAULT_INPUTS_O_FORM = [
  // show-header [boolean]: visibility of form toolbar. Default: yes.
  'showHeader: show-header',

  // header-mode [string][ none | floating ]: painting mode of form toolbar. Default: 'floating'
  'headerMode: header-mode',

  // header-position [ top | bottom ]: position of the form toolbar. Default: 'top'
  'headerPosition: header-position',

  // label-header [string]: displayable text on form toolbar. Default: ''.
  'labelheader: label-header',

  // label-header-align [string][start | center | end]: alignment of form toolbar text. Default: 'center'
  'labelHeaderAlign: label-header-align',

  // header-actions [string]: available action buttons on form toolbar of standard CRUD operations, separated by ';'. Available options are R;I;U;D (Refresh, Insert, Update, Delete). Default: R;I;U;D
  'headeractions: header-actions',

  // show-header-actions-text [string][yes|no|true|false]: show text of form toolbar buttons. Default yes
  'showHeaderActionsText: show-header-actions-text',

  // entity [string]: entity of the service. Default: no value.
  'entity',

  // keys [string]: entity keys, separated by ';'. Default: no value.
  'keys',

  // columns [string]: columns of the entity, separated by ';'. Default: no value.
  'columns',

  // service [string]: JEE service path. Default: no value.
  'service',

  // stay-in-record-after-edit [string][yes|no|true|false]: shows edit form after edit a record. Default: false;
  'stayInRecordAfterEdit: stay-in-record-after-edit',

  // [string][new | detail]: shows reseted form after insert a new record (new) or shows the inserted record after (detail)
  'afterInsertMode: after-insert-mode',

  'serviceType : service-type',

  'queryOnInit : query-on-init',

  'parentKeys: parent-keys',

  // query-method [string]: name of the service method to perform queries. Default: query.
  'queryMethod: query-method',

  // insert-method [string]: name of the service method to perform inserts. Default: insert.
  'insertMethod: insert-method',

  // update-method [string]: name of the service method to perform updates. Default: update.
  'updateMethod: update-method',

  // delete-method [string]: name of the service method to perform deletions. Default: delete.
  'deleteMethod: delete-method',

  // layout-direction [string][column|row]: Default: column
  'layoutDirection: layout-direction',

  // fxLayoutAlign value
  'layoutAlign: layout-align',

  // editable-detail [string][yes|no|true|false]: Default: true;
  'editableDetail: editable-detail',

  // keys-sql-types [string]: entity keys types, separated by ';'. Default: no value.
  'keysSqlTypes: keys-sql-types',

  // undo-button [string][yes|no|true|false]: Include undo button in form-toolbar. Default: true;
  'undoButton: undo-button',

  // show-header-navigation [string][yes|no|true|false]: Include navigations buttons in form-toolbar. Default: false;
  'showHeaderNavigation: show-header-navigation',

  // attr
  'oattr:attr',

  'includeBreadcrumb: include-breadcrumb',

  'detectChangesOnBlur: detect-changes-on-blur',

  'confirmExit: confirm-exit',

  // [function]: function to execute on query error. Default: no value.
  'queryFallbackFunction: query-fallback-function'
  // ,

  // 'insertFallbackFunction: insert-fallback-function',

  // 'updateFallbackFunction: update-fallback-function',

  // 'deleteFallbackFunction: delete-fallback-function'
];

export const DEFAULT_OUTPUTS_O_FORM = [
  'onDataLoaded',
  'beforeCloseDetail',
  'beforeGoEditMode',
  'onFormModeChange',
  'onInsert',
  'onUpdate',
  'onDelete'
];
@Component({
  selector: 'o-form',
  providers: [
    OntimizeServiceProvider
  ],
  templateUrl: './o-form.component.html',
  styleUrls: ['./o-form.component.scss'],
  inputs: DEFAULT_INPUTS_O_FORM,
  outputs: DEFAULT_OUTPUTS_O_FORM,
  encapsulation: ViewEncapsulation.None,
  host: {
    '[class.o-form]': 'true'
  }
})
export class OFormComponent implements OnInit, OnDestroy, CanComponentDeactivate, AfterViewInit {

  // public static RELOAD_ACTION: string = 'RELOAD';
  // public static GO_EDIT_ACTION: string = 'GO_EDIT';
  // public static EDIT_ACTION: string = 'EDIT';
  // public static INSERT_ACTION: string = 'INSERT';
  // public static GO_INSERT_ACTION: string = 'GO_INSERT';
  // public static DELETE_ACTION: string = 'DELETE';
  // public static UNDO_LAST_CHANGE_ACTION: string = 'UNDO_LAST_CHANGE';

  public static DEFAULT_LAYOUT_DIRECTION = 'column';
  public static guardClassName = 'CanDeactivateFormGuard';

  /* inputs variables */
  @InputConverter()
  showHeader: boolean = true;
  headerMode: string = 'floating';
  headerPosition: 'top' | 'bottom' = 'top';
  labelheader: string = '';
  labelHeaderAlign: string = 'center';
  headeractions: string = '';
  showHeaderActionsText: string = 'yes';
  entity: string;
  keys: string = '';
  columns: string = '';
  service: string;
  @InputConverter()
  stayInRecordAfterEdit: boolean = false;
  afterInsertMode: 'new' | 'detail' = null;
  serviceType: string;
  @InputConverter()
  protected queryOnInit: boolean = true;
  protected parentKeys: string;
  protected queryMethod: string = Codes.QUERY_METHOD;
  protected insertMethod: string = Codes.INSERT_METHOD;
  protected updateMethod: string = Codes.UPDATE_METHOD;
  protected deleteMethod: string = Codes.DELETE_METHOD;
  protected _layoutDirection: string = OFormComponent.DEFAULT_LAYOUT_DIRECTION;<commit_msg>Deleting commented code<commit_after>import {
  AfterViewInit,
  ChangeDetectorRef,
  Component,
  ElementRef,
  EventEmitter,
  Injector,
  NgZone,
  OnDestroy,
  OnInit,
  ViewChild,
  ViewEncapsulation,
} from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { ActivatedRoute, Router, UrlSegment } from '@angular/router';
import { BehaviorSubject, combineLatest, Observable, Subscription } from 'rxjs';

import { InputConverter } from '../../decorators/input-converter';
import { IComponent } from '../../interfaces/component.interface';
import { IFormDataComponent } from '../../interfaces/form-data-component.interface';
import { IFormDataTypeComponent } from '../../interfaces/form-data-type-component.interface';
import { ServiceResponse } from '../../interfaces/service-response.interface';
import { OFormLayoutManagerComponent } from '../../layouts/form-layout/o-form-layout-manager.component';
import { OntimizeServiceProvider } from '../../services/data-service.provider';
import { DialogService } from '../../services/dialog.service';
import { NavigationService, ONavigationItem } from '../../services/navigation.service';
import { OntimizeService } from '../../services/ontimize/ontimize.service';
import { PermissionsService } from '../../services/permissions/permissions.service';
import { SnackBarService } from '../../services/snackbar.service';
import { FormValueOptions } from '../../types/form-value-options.type';
import { OFormInitializationOptions } from '../../types/o-form-initialization-options.type';
import { OFormPermissions } from '../../types/o-form-permissions.type';
import { OPermissions } from '../../types/o-permissions.type';
import { Codes } from '../../util/codes';
import { SQLTypes } from '../../util/sqltypes';
import { Util } from '../../util/util';
import { OFormContainerComponent } from '../form-container/o-form-container.component';
import { OFormControl } from '../input/o-form-control.class';
import { OFormCacheClass } from './cache/o-form.cache.class';
import { CanComponentDeactivate, CanDeactivateFormGuard } from './guards/o-form-can-deactivate.guard';
import { OFormNavigationClass } from './navigation/o-form.navigation.class';
import { OFormValue } from './OFormValue';
import { OFormToolbarComponent } from './toolbar/o-form-toolbar.component';

interface IFormDataComponentHash {
  [attr: string]: IFormDataComponent;
}

export const DEFAULT_INPUTS_O_FORM = [
  // show-header [boolean]: visibility of form toolbar. Default: yes.
  'showHeader: show-header',

  // header-mode [string][ none | floating ]: painting mode of form toolbar. Default: 'floating'
  'headerMode: header-mode',

  // header-position [ top | bottom ]: position of the form toolbar. Default: 'top'
  'headerPosition: header-position',

  // label-header [string]: displayable text on form toolbar. Default: ''.
  'labelheader: label-header',

  // label-header-align [string][start | center | end]: alignment of form toolbar text. Default: 'center'
  'labelHeaderAlign: label-header-align',

  // header-actions [string]: available action buttons on form toolbar of standard CRUD operations, separated by ';'. Available options are R;I;U;D (Refresh, Insert, Update, Delete). Default: R;I;U;D
  'headeractions: header-actions',

  // show-header-actions-text [string][yes|no|true|false]: show text of form toolbar buttons. Default yes
  'showHeaderActionsText: show-header-actions-text',

  // entity [string]: entity of the service. Default: no value.
  'entity',

  // keys [string]: entity keys, separated by ';'. Default: no value.
  'keys',

  // columns [string]: columns of the entity, separated by ';'. Default: no value.
  'columns',

  // service [string]: JEE service path. Default: no value.
  'service',

  // stay-in-record-after-edit [string][yes|no|true|false]: shows edit form after edit a record. Default: false;
  'stayInRecordAfterEdit: stay-in-record-after-edit',

  // [string][new | detail]: shows reseted form after insert a new record (new) or shows the inserted record after (detail)
  'afterInsertMode: after-insert-mode',

  'serviceType : service-type',

  'queryOnInit : query-on-init',

  'parentKeys: parent-keys',

  // query-method [string]: name of the service method to perform queries. Default: query.
  'queryMethod: query-method',

  // insert-method [string]: name of the service method to perform inserts. Default: insert.
  'insertMethod: insert-method',

  // update-method [string]: name of the service method to perform updates. Default: update.
  'updateMethod: update-method',

  // delete-method [string]: name of the service method to perform deletions. Default: delete.
  'deleteMethod: delete-method',

  // layout-direction [string][column|row]: Default: column
  'layoutDirection: layout-direction',

  // fxLayoutAlign value
  'layoutAlign: layout-align',

  // editable-detail [string][yes|no|true|false]: Default: true;
  'editableDetail: editable-detail',

  // keys-sql-types [string]: entity keys types, separated by ';'. Default: no value.
  'keysSqlTypes: keys-sql-types',

  // undo-button [string][yes|no|true|false]: Include undo button in form-toolbar. Default: true;
  'undoButton: undo-button',

  // show-header-navigation [string][yes|no|true|false]: Include navigations buttons in form-toolbar. Default: false;
  'showHeaderNavigation: show-header-navigation',

  // attr
  'oattr:attr',

  'includeBreadcrumb: include-breadcrumb',

  'detectChangesOnBlur: detect-changes-on-blur',

  'confirmExit: confirm-exit',

  // [function]: function to execute on query error. Default: no value.
  'queryFallbackFunction: query-fallback-function'
  // ,

  // 'insertFallbackFunction: insert-fallback-function',

  // 'updateFallbackFunction: update-fallback-function',

  // 'deleteFallbackFunction: delete-fallback-function'
];

export const DEFAULT_OUTPUTS_O_FORM = [
  'onDataLoaded',
  'beforeCloseDetail',
  'beforeGoEditMode',
  'onFormModeChange',
  'onInsert',
  'onUpdate',
  'onDelete'
];
@Component({
  selector: 'o-form',
  providers: [
    OntimizeServiceProvider
  ],
  templateUrl: './o-form.component.html',
  styleUrls: ['./o-form.component.scss'],
  inputs: DEFAULT_INPUTS_O_FORM,
  outputs: DEFAULT_OUTPUTS_O_FORM,
  encapsulation: ViewEncapsulation.None,
  host: {
    '[class.o-form]': 'true'
  }
})
export class OFormComponent implements OnInit, OnDestroy, CanComponentDeactivate, AfterViewInit {

  public static DEFAULT_LAYOUT_DIRECTION = 'column';
  public static guardClassName = 'CanDeactivateFormGuard';

  /* inputs variables */
  @InputConverter()
  showHeader: boolean = true;
  headerMode: string = 'floating';
  headerPosition: 'top' | 'bottom' = 'top';
  labelheader: string = '';
  labelHeaderAlign: string = 'center';
  headeractions: string = '';
  showHeaderActionsText: string = 'yes';
  entity: string;
  keys: string = '';
  columns: string = '';
  service: string;
  @InputConverter()
  stayInRecordAfterEdit: boolean = false;
  afterInsertMode: 'new' | 'detail' = null;
  serviceType: string;
  @InputConverter()
  protected queryOnInit: boolean = true;
  protected parentKeys: string;
  protected queryMethod: string = Codes.QUERY_METHOD;
  protected insertMethod: string = Codes.INSERT_METHOD;
  protected updateMethod: string = Codes.UPDATE_METHOD;
  protected deleteMethod: string = Codes.DELETE_METHOD;
  protected _layoutDirection: string = OFormComponent.DEFAULT_LAYOUT_DIRECTION;
{'fraction_non_alphanumeric': 0.14178323963916853, 'fraction_numerical': 0.0, 'mean_word_length': 4.343695424380021, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2371112', 'n_tokens_mistral': 4511, 'n_tokens_neox': 4449, 'n_words': 1170}