### File

`projects/app-base-library/src/lib/shared/ui/form.ts`

### Index

###### Properties

- Public $form
- Public bundle
- Public resource

### Constructor

`constructor($formRef: , resourceRef: )`
Defined in projects/app-base-library/src/lib/shared/ui/form.ts:5

Parameters :

Name | Optional
$formRef | no
resourceRef | no

### Properties

Public $form
`$form: `any``
Type : `any`
Default value : `{}`
Defined in projects/app-base-library/src/lib/shared/ui/form.ts:3

Public bundle
`bundle: `string``
Type : `string`
Default value : `''`
Defined in projects/app-base-library/src/lib/shared/ui/form.ts:5

Public resource
`resource: `any``
Type : `any`
Default value : `{}`
Defined in projects/app-base-library/src/lib/shared/ui/form.ts:4

    export class Form {

        public $form: any = {};
        public resource: any = {};
        public bundle = '';

        constructor($formRef, resourceRef) {
            this.$form = $formRef;
            this.resource = resourceRef;
            if (this.resource.bundle) {
                this.bundle = this.resource.bundle;
            }
        }

        // enableForm($form){
        //     // $form.$submitted = false;
        //     $form.find(":input:not(.always-disabled)").prop('readonly', false);
        //     $form.find(":input:not(.always-disabled)").prop('disabled', false);
        //     $form.find("select:not(.always-disabled)").prop('disabled', false);
        //     $form.find("multiselect:not(.always-disabled)").attr('disabled', false);
        //     $form.find("at-datepicker:not(.always-disabled)").attr('disabled', false);
        //     this.applyFieldPermissions();
        //     angular.element($form).find('at-crud-toolbar button').each(function(){
        //         angular.element(this).prop('disabled', false);
        //     });
        // }

        // disableForm($form){
        //     $form.find(":input").prop('readonly', true);
        //     $form.find(":input").prop('disabled', true);
        //     $form.find("select").prop('disabled', true);
        //     $form.find("multiselect").attr('disabled', true);
        //     $form.find("at-datepicker").attr('disabled', true);
        //     this.applyFieldPermissions();
        //     angular.element($form).find('at-crud-toolbar button').each(function (){
        //         angular.element(this).prop('disabled', false);
        //         angular.element(this).prop('readonly', false);
        //     });
        //     angular.element($form).find('[at-crud]').each(function(i){
        //         var $el = angular.element(this);
        //         var crud = Api.getPermission($el.attr('at-crud'));
        //     });
        // }

        // applyFieldPermissions(){
        //     if(vm.active === 'false'){return}
        //     //console.log('applyFieldPermissions: '+vm.bundle);
        //     if(vm.bundle){
        //         angular.element($element).find("[ng-model]").each(function(i){
        //             var bundle = vm.bundle;
        //             var arr =  angular.element(this).attr('ng-model').split('.');
        //             var field = arr[arr.length-1];
        //             var crud = Api.getPermission(bundle+'.'+field);
        //             //console.log(field);
        //             //console.log(crud);
        //             var $this = angular.element(this);
        //             // no read
        //             if(crud[1]===false){
        //                 $this.closest('div[valdr-form-group]').hide();
        //             }
        //             // no update + no delete
        //             if(crud[2]===false || crud[3]===false){
        //                 $this.prop('readonly', true);
        //                 $this.prop('disabled', true);
        //             }
        //             // update + no delete
        //             if(crud[2]===true && crud[3]===false && $scope.editForm){
        //                 $this.prop('readonly', false);
        //                 $this.prop('disabled', false);
        //             }
        //             // create
        //             if(crud[0]===true && $scope.newForm === true){
        //                 if(!$this.hasClass('always-disabled')){
        //                     $this.prop('readonly', false);
        //                     $this.prop('disabled', false);
        //                 };
        //             }
        //         });
        //     }
        // }

    }

# results matching ""

# No results matching ""