Skip to content

Commit

Permalink
Remove unnecessary validation code #75
Browse files Browse the repository at this point in the history
  • Loading branch information
hikalkan committed Jul 4, 2017
1 parent f1ac222 commit b016e39
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 104 deletions.
26 changes: 7 additions & 19 deletions angular/src/app/roles/create-role/create-role.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { RoleServiceProxy, CreateRoleDto, ListResultDtoOfPermissionDto } from '@
import { AppComponentBase } from '@shared/app-component-base';

@Component({
selector: 'create-role-modal',
templateUrl: './create-role.component.html'
selector: 'create-role-modal',
templateUrl: './create-role.component.html'
})
export class CreateRoleComponent extends AppComponentBase implements OnInit {
@ViewChild('createRoleModal') modal: ModalDirective;
@ViewChild('modalContent') modalContent: ElementRef;
@ViewChild('createRoleModal') modal: ModalDirective;
@ViewChild('modalContent') modalContent: ElementRef;

active: boolean = false;
saving: boolean = false;
Expand All @@ -27,8 +27,7 @@ export class CreateRoleComponent extends AppComponentBase implements OnInit {

ngOnInit(): void {
this._roleService.getAllPermissions()
.subscribe((permissions:ListResultDtoOfPermissionDto) =>
{
.subscribe((permissions: ListResultDtoOfPermissionDto) => {
this.permissions = permissions;
});
}
Expand All @@ -42,31 +41,20 @@ export class CreateRoleComponent extends AppComponentBase implements OnInit {

onShown(): void {
$.AdminBSB.input.activate($(this.modalContent.nativeElement));

$('#frm_create_role').validate({
highlight: input => {
$(input).parents('.form-line').addClass('error');
},
unhighlight: input => {
$(input).parents('.form-line').removeClass('error');
},
errorPlacement: (error, element) => {
$(element).parents('.form-group').append(error);
}
});
}

save(): void {
var permissions = [];
$(this.modalContent.nativeElement).find("[name=permission]").each(
(index: number, elem: Element) => {
if ($(elem).is(":checked") == true) {
if ($(elem).is(":checked")) {
permissions.push(elem.getAttribute("value").valueOf());
}
}
);

this.role.permissions = permissions;

this.saving = true;
this._roleService.create(this.role)
.finally(() => { this.saving = false; })
Expand Down
8 changes: 1 addition & 7 deletions angular/src/app/roles/edit-role/edit-role.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">
<span>{{l("EditRole")}}</span>
<span>{{l("EditRole")}} <span *ngIf="role.isStatic"> (<span style="color:red">static</span>)</span></span>
</h4>
</div>
<div class="modal-body">
Expand Down Expand Up @@ -48,12 +48,6 @@ <h4 class="modal-title">
</div>
</div>

<div class="row" *ngIf="role.isStatic">
<div class="col-sm-12">
<p style="color:red">Static Role</p>
</div>
</div>

<div class="row clearfix">
<div class="col-sm-12">
<h4>Permissions</h4>
Expand Down
12 changes: 0 additions & 12 deletions angular/src/app/roles/edit-role/edit-role.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,6 @@ export class EditRoleComponent extends AppComponentBase implements OnInit {

onShown(): void {
$.AdminBSB.input.activate($(this.modalContent.nativeElement));

$('#frm_edit_role').validate({
highlight: function (input) {
$(input).parents('.form-line').addClass('error');
},
unhighlight: function (input) {
$(input).parents('.form-line').removeClass('error');
},
errorPlacement: function (error, element) {
$(element).parents('.form-group').append(error);
}
});
}

checkPermission(permissionName: string): string {
Expand Down
11 changes: 2 additions & 9 deletions angular/src/app/roles/roles.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,14 @@ <h2>
<thead>
<tr>
<th>{{l('RoleName')}}</th>
<th>{{l('Description')}}</th>
<th>
<div style="text-align:center">{{l('IsActive')}}</div>
</th>
<th>{{l('DisplayName')}}</th>
<th>{{l('Actions')}}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let role of roles | paginate: { id: 'server', itemsPerPage: pageSize, currentPage: pageNumber, totalItems: totalItems }">
<td>{{role.name}}</td>
<td>{{role.displayName}}</td>
<td>{{role.description}}</td>
<td align="center">
<i class="material-icons" *ngIf="role.isActive" style="color:green;">check_box</i>
<i class="material-icons" *ngIf="!role.isActive" style="color:red;">indeterminate_check_box</i>
</td>
<td class="dropdown">
<a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<i class="material-icons">menu</i>
Expand Down
12 changes: 0 additions & 12 deletions angular/src/app/tenants/create-tenant/create-tenant.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@ export class CreateTenantComponent extends AppComponentBase {

onShown(): void {
$.AdminBSB.input.activate($(this.modalContent.nativeElement));

$('#frm_create_tenant').validate({
highlight: input => {
$(input).parents('.form-line').addClass('error');
},
unhighlight: input => {
$(input).parents('.form-line').removeClass('error');
},
errorPlacement: (error, element) => {
$(element).parents('.form-group').append(error);
}
});
}

save(): void {
Expand Down
12 changes: 0 additions & 12 deletions angular/src/app/tenants/edit-tenant/edit-tenant.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,6 @@ export class EditTenantComponent extends AppComponentBase{

onShown(): void {
$.AdminBSB.input.activate($(this.modalContent.nativeElement));

$('#frm_edit_tenant').validate({
highlight(input) {
$(input).parents('.form-line').addClass('error');
},
unhighlight(input) {
$(input).parents('.form-line').removeClass('error');
},
errorPlacement(error, element) {
$(element).parents('.form-group').append(error);
}
});
}

save(): void {
Expand Down
12 changes: 0 additions & 12 deletions angular/src/app/users/create-user/create-user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@ export class CreateUserComponent extends AppComponentBase implements OnInit {

onShown(): void {
$.AdminBSB.input.activate($(this.modalContent.nativeElement));

$('#frm_create_user').validate({
highlight: input => {
$(input).parents('.form-line').addClass('error');
},
unhighlight: input => {
$(input).parents('.form-line').removeClass('error');
},
errorPlacement: (error, element) => {
$(element).parents('.form-group').append(error);
}
});
}

save(): void {
Expand Down
13 changes: 1 addition & 12 deletions angular/src/app/users/edit-user/edit-user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,12 @@ export class EditUserComponent extends AppComponentBase {

onShown(): void {
$.AdminBSB.input.activate($(this.modalContent.nativeElement));
$('#frm_edit_user').validate({
highlight: input => {
$(input).parents('.form-line').addClass('error');
},
unhighlight: input => {
$(input).parents('.form-line').removeClass('error');
},
errorPlacement: (error, element) => {
$(element).parents('.form-group').append(error);
}
});
}

save(): void {
var roles = [];
$(this.modalContent.nativeElement).find("[name=role]").each(function(ind:number, elem:Element){
if($(elem).is(":checked") == true){
if($(elem).is(":checked")){
roles.push(elem.getAttribute("value").valueOf());
}
});
Expand Down
8 changes: 1 addition & 7 deletions angular/src/shared/service-proxies/service-proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,6 @@ export class CreateRoleDto {
displayName: string;
normalizedName: string;
description: string;
isActive: boolean;
isStatic: boolean;
permissions: string[];
constructor(data?: any) {
Expand All @@ -1406,7 +1405,6 @@ export class CreateRoleDto {
this.displayName = data["displayName"] !== undefined ? data["displayName"] : null;
this.normalizedName = data["normalizedName"] !== undefined ? data["normalizedName"] : null;
this.description = data["description"] !== undefined ? data["description"] : null;
this.isActive = data["isActive"] !== undefined ? data["isActive"] : null;
this.isStatic = data["isStatic"] !== undefined ? data["isStatic"] : null;
if (data["permissions"] && data["permissions"].constructor === Array) {
this.permissions = [];
Expand All @@ -1426,7 +1424,6 @@ export class CreateRoleDto {
data["displayName"] = this.displayName !== undefined ? this.displayName : null;
data["normalizedName"] = this.normalizedName !== undefined ? this.normalizedName : null;
data["description"] = this.description !== undefined ? this.description : null;
data["isActive"] = this.isActive !== undefined ? this.isActive : null;
data["isStatic"] = this.isStatic !== undefined ? this.isStatic : null;
if (this.permissions && this.permissions.constructor === Array) {
data["permissions"] = [];
Expand Down Expand Up @@ -2062,8 +2059,7 @@ export class CreateUserDto {
emailAddress: string;
isActive: boolean;
roles: string[];
password: string;
confirmPassword: string;
password: string;
constructor(data?: any) {
if (data !== undefined) {
this.userName = data["userName"] !== undefined ? data["userName"] : null;
Expand All @@ -2077,7 +2073,6 @@ export class CreateUserDto {
this.roles.push(item);
}
this.password = data["password"] !== undefined ? data["password"] : null;
this.confirmPassword = data["confirmPassword"] !== undefined ? data["confirmPassword"] : null;
}
}

Expand All @@ -2098,7 +2093,6 @@ export class CreateUserDto {
data["roles"].push(item);
}
data["password"] = this.password !== undefined ? this.password : null;
data["confirmPassword"] = this.confirmPassword !== undefined ? this.confirmPassword : null;
return data;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public class CreateRoleDto
[StringLength(Role.MaxDescriptionLength)]
public string Description { get; set; }

public bool IsActive { get; set; }

public bool IsStatic { get; set; }

public List<string> Permissions { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
<text name="Back">Geri</text>
<text name="SuccessfullyRegistered">Başarıyla kayıt olundu</text>
<text name="WaitingForEmailActivation">E-posta adresiniz etkinleştirilmeli.</text>
<text name="Roles">Roller</text>
<text name="DisplayName">Görünen ad</text>

</texts>
</localizationDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<text name="SuccessfullyRegistered">Successfully registered</text>
<text name="WaitingForEmailActivation">Your email address should be activated</text>
<text name="Roles">Roles</text>
<text name="DisplayName">Display Name</text>

</texts>
</localizationDictionary>

0 comments on commit b016e39

Please sign in to comment.