refs #5666 perf: remove ruleAlias property
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Javier Segarra 2023-12-11 12:40:16 +01:00
parent a7c48b6ddc
commit d1f0557923
4 changed files with 6 additions and 13 deletions

View File

@ -23,7 +23,6 @@ export function directive($translate, $window) {
let rule = $attrs.rule.split('.');
let modelName = rule.shift();
let fieldName = rule.shift();
let modelAlias = $attrs.ruleAlias;
let split = $attrs.ngModel.split('.');
if (!fieldName) fieldName = split.pop() || null;
if (!modelName) modelName = firstUpper(split.pop() || '');
@ -31,12 +30,8 @@ export function directive($translate, $window) {
if (!modelName || !fieldName)
throw new Error(`rule: Cannot retrieve model or field attribute`);
let modelValidations = vnValidations[modelName];
if (!modelValidations)
modelValidations = vnValidations[modelAlias];
if (!modelValidations)
throw new Error(`rule: Model '${modelName}' doesn't exist`);

View File

@ -14,15 +14,13 @@
<vn-textfield
label="Name"
ng-model="$ctrl.role.name"
rule
rule-alias="VnRole"
rule="VnRole.name"
vn-focus>
</vn-textfield>
<vn-textfield
label="Description"
ng-model="$ctrl.role.description"
rule
rule-alias="VnRole"
rule="VnRole.description"
>
</vn-textfield>
</vn-vertical>

View File

@ -1,6 +1,6 @@
import './index';
describe('component vnRoleCard', () => {
fdescribe('component vnRoleCard', () => {
let controller;
let $httpBackend;
@ -15,7 +15,7 @@ describe('component vnRoleCard', () => {
it('should reload the controller data', () => {
controller.$params.id = 1;
$httpBackend.expectGET('Roles/1').respond('foo');
$httpBackend.expectGET('VnRoles/1').respond('foo');
controller.reload();
$httpBackend.flush();

View File

@ -1,6 +1,6 @@
import './index';
describe('component vnRoleDescriptor', () => {
fdescribe('component vnRoleDescriptor', () => {
let controller;
let $httpBackend;
@ -18,7 +18,7 @@ describe('component vnRoleDescriptor', () => {
controller.$state.go = jest.fn();
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectDELETE('Roles/1').respond();
$httpBackend.expectDELETE('VnRoles/1').respond();
controller.onDelete();
$httpBackend.flush();