Table and Array filtering/pipe - html

i'm trying to pipe the values of my table to show only the things i want, actually with "EMPRESAS", "TIPO USUARIO"; it's working(with some errors but i will study on my own to fix that). But with status i get the return of how many "ATIVOS", and "INATIVOS" i got, but when i trying to list him in the table, in my ATIVOS appear the INATIVO, how to fix that? i thing its something happening because inATIVOS and ATIVOS had commun chars, btw i don't know how to fix that
<div class="row">
<div class="col-md-12">
<app-card cardTitle="Informe os parâmetros da pesquisa">
<form (ngSubmit)="onSubmit(selectVal.value, selectedOption)">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label class=" form-label"
style="font-weight: bold;"
>Filtrar pesquisa</label>
<select class="form-control" #selectVal name="filterOption" formControlName="filterOption">
<option value="TODOS">TODOS</option>
<option value="empresa">EMPRESAS</option>
<option value="tipo_usuario">TIPO DO USUÁRIO</option>
<option value="status">STATUS DO USUÁRIO</option>
</select>
</div>
</div>
<div
*ngIf="selectVal.value == 'empresa'"
class="var-select" class="col-md-2">
<div class="form-group">
<div >
<label class="form-label"
style="font-weight: bold">Empresa</label>
<select class="form-control" name="empresa" [(ngModel)]="selectedOption" >
<option *ngFor="let usuario of usuarios | pEmpresa : selectedOption" value={{usuario.empresa}}> {{usuario.empresa}}</option>
</select>
</div>
</div>
</div>
<div
*ngIf="selectVal.value == 'tipo_usuario'"
class="var-select" class="col-md-2">
<div class="form-group">
<div>
<label class="form-label" style="font-weight: bold">Tipos do usuário</label>
<select class="form-control" name="tipo_usuario" [(ngModel)]="selectedOption">
<option *ngFor="let usuario of usuarios | pTipo : selectedOption " value={{usuario.tipo_usuario}}>{{usuario.tipo_usuario}} </option>
</select>
</div>
</div>
</div>
<div
*ngIf="selectVal.value == 'status'"
class="var-select" class="col-md-2">
<div class="form-group">
<div >
<label class="form-label" style="font-weight: bold">Status dos usuários</label>
<select class="form-control" name="status" [(ngModel)]="selectedOption">
<option *ngFor="let usuario of usuarios | pStatus : selectedOption" value={{usuario.status}}>{{usuario.status}}</option>
</select>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<div class="col-md-12">
<button type="submit" class="btn btn-warning pos">CONSULTAR</button>
</div>
</div>
</div>
</form>
</app-card>
</div>
</div>
<div class="row">
<div class="col-md-12">
<button type="submit" class="btn btn-success" (click)="cadastrarNovoUsuario()">Cadastrar Usuario</button>
</div>
</div>
<br>
<div class="row">
<div class="col-md-12" *ngIf="carregar_lista_usuarios">
<app-card cardTitle="Usuários" cardClass="card-datatable" [options]="false">
<div class="table-responsive col-md-12">
<table datatable [dtOptions]="dtResponsiveOptions" class="table table-striped table-bordered table-hover" >
<thead>
<tr>
<th style="visibility: hidden; width: 1%; border-collapse: inherit; border-color: transparent;"></th>
<th>NOME</th>
<!-- <th>UID</th> -->
<th>EMPRESA</th>
<th>E-MAIL</th>
<th>TELEFONE</th>
<th>STATUS</th>
<th>AÇÃO</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let usuario of usuarios | filter : selectedOption">
<div class="imagem text vasco" style="border-radius: 80%; height: 60px; border-color: transparent;" ><img
[src]="usuario.imagem_url == '' || usuario.imagem_url == 'null' ? asset : usuario.imagem_url" class="img-radius align-center" style="width:45px"></div>
<td class="text" style="width: 5%; max-width: 4.8rem;">{{usuario.nome_usuario}}</td>
<!-- <td style="width: 1%;">{{usuario.uid}}</td> -->
<td class="text" style="width: 11%; max-width: 5.7rem">{{usuario.empresa}}</td>
<td class="text" style="width: 10%; max-width: 10.9rem">{{usuario.email}}</td>
<td mask="(00)0 0000 0000" class="text" style="width: 10%; max-width: 4rem">{{usuario.celular}}</td>
<td class="text" style="width: 10%; max-width: 3rem">{{usuario.status}}</td>
<td class="text" style="width: 10%;">
<button type="submit" class="btn btn-success" (click)="editarUsuario(usuario.uid)"><i class="feather icon-edit"></i></button>
<button *ngIf="adm_op" type="submit" class="btn btn-danger" (click)="apagarUsuario(usuario.uid)"><i class="feather icon-x-circle"></i></button></td>
</tr>
</tbody>
</table>
</div>
</app-card>
</div>
</div>
This is the PIPE i'm using in the HTML
Pipe.TS
#Pipe({name: "pStatus"})
export class PipeStatus implements PipeTransform {
transform(usuarios: Array<Usuario>, selectedOption){
let result = []
let obj = {}
let obj2 = 'status'
console.log("SELECIONADO: " , selectedOption)
usuarios.forEach((item, i) => {
obj[item[obj2]] = i;
console.log("value", item.status)
});
for(let key in obj){
let idx = obj[key]
console.log("IDX", idx, "OBJ for", obj, 'KEY', key)
result.push(usuarios[idx])
}
return result
```

Related

Can't get value from form in AngularJS

I tried this student manager in HTML+ java last time. So now I want to try in angularJS. When I finished my code, it doesn't seem to work.
There are no error in console so I don't know where I went wrong. Can someone help me to figure out what the error is here?
HTML
<div ng-controll="MyController">
<form role="form" ng-submit="saveStudent()">
<div class="form-group mt-2">
<label for="" class="form-label">Student Name: </label>
<input type="text" required placeholder="Enter student name" class="form-control" ng-model="name">
</div>
<div class="form-group mt-2">
<label for="" class="form-label">Student DOB: </label>
<input type="date" placeholder="mm/dd/yyyy" class="form-control" ng-model="birth">
</div>
<div class="form-group mt-2">
<label for="" class="form-label">Student Gender: </label>
<input type="radio" name="sex" value="male" ng-model="sex" id="male">
<label for="male">Male</label>
<input type="radio" name="sex" value="female" ng-model="sex" id="female">
<label for="female">Female</label>
</div>
<div class="form-group mt-2">
<label for="" class="form-label">Student Language: </label>
<label for="" ng-repeat="language in languagesList">
<input type="checkbox" value="{{language.name}}" ng-checked="checkboxModel.indexOf(language) > -1" ng-click="addLanguage(language)">{{language}}
</label>
</div>
<div class="form-group mt-2">
<label for="">Student Class: </label>
<select name="student_class" class="form-control" ng-model="studentclass">
<option value="">---Select---</option>
<option value="{{ item }}" ng-repeat="item in classList">{{ item }}</option>
</select>
</div>
<div class="form-group mt-2 pb-3">
<button class="btn btn-danger" type="submit">Add</button>
</div>
</form>
<br><br><br>
<div class="card-table " style="margin-top: 20px;">
<h2 style="text-align: center;">Student List</h2>
<div class="content">
<table border="1">
<thead>
<tr>
<th>Name</th>
<th>Class</th>
<th>DOB</th>
<th>Gender</th>
<th>Language</th>
<th></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in studentList track by $index">
<td>{{ item.name }}</td>
<td>{{ item.studentclass }}</td>
<td>{{ item.birth | date}}</td>
<td>{{ item.sex }}</td>
<td>
<div ng-repeat="checkbox in item.checkboxModel">
{{ checkbox }}
</div>
</td>
<td>
<a href="#" class="btn btn-danger" ng-click="removeStudent($index)" style="color: blue;">Delete</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
Angular JS
var app = angular.module('MyApp', []);
app.controller('MyController', ['$scope', function ($scope) {
$scope.studentList = [];
$scope.classList = ['C2108G1',
'C2108G2',
'C2108G3',
'C2108G4',
'C2108G5',
'C2108L'
];
$scope.languagesList = [
'English',
'Vietnamese',
'Japanese',
'Chinese',
'French'
];
$scope.checkboxModel = [];
$scope.addLanguage = function (language) {
var index = $scope.checkboxModel.indexOf(language);
if (index > -1) {
$scope.checkboxModel.splice(index, 1);
} else {
$scope.checkboxModel.push(language);
}
}
$scope.saveStudent = function () {
var item = {
'name': $scope.name,
'birth': $scope.birth,
'sex': $scope.sex,
'studentclass': $scope.studentclass,
'checkboxModel': $scope.checkboxModel,
}
if ($scope.currentIndex >= 0) {
$scope.studentList[$scope.currentIndex] = item;
$scope.currentIndex = -1;
} else {
$scope.studentList.push(item);
}
}
$scope.currentIndex = -1;
$scope.removeStudent = function (index) {
var option = confirm('Are you sure you want to remove this student?');
if (!option) return;
$scope.studentList.splice(index, 1);
}
}]);

Codeigniter MySQL update

I have MySQL database used with Codigniter including following table too.
+-------------------+-----------------+------+-------+--------+
| update_request_id | update_stock_id | item | r_qty | status |
+-------------------+-----------------+------+-------+--------+
And used the following for loop in Controller, to update records in the table.
$count = count($this->input->post('item_id'));
$items = $this->input->post('item_id');
$qts = $this->input->post('qty');
for ($x = 0; $x < $count; $x++) {
$udetails[$x]['update_stock_id'] = $id;
$udetails[$x]['item'] = $items[$x];
$udetails[$x]['r_qty'] = $qts[$x];
$udetails[$x]['status'] = 1;
}
And the following View used to get relevant values for the controller.
<?php
if(!empty($itemReqFromHD)){
$newMaster=$itemReqFromHD[0];
}
?>
<script type="text/javascript">
$(document).on("change", "#item", function () {
$.ajax({
'url': '<?=site_url("item/isExistProduct/?q=")?>' + $('#item').val(),
'method': 'GET',
'success': function (data) {
//console.log(data);
var jData = JSON.parse(data);
if (jData.status == true) {
$('#request_table').append('<tr>' +
'<td ><span id="product" >' + jData.data[0].item_name + '</span>' +
'<input type="hidden" id="item_id[]" name="item_id[]" value="'+jData.data[0].item_id+'">' +
'</td>' +
'<td class="text-center"><input class="form-control" autofocus required type="number" step="any" id="qty['+jData.data[0].item_id+']" name="qty['+jData.data[0].item_id+']" ></td>' +
'<td class="text-center" ><i class="fa fa-remove remove" style="cursor: pointer"></i></td>' +
'</tr>');
}
},
'error': function () {
}
});
});
$(document).on("click", ".remove", function () {
$(this).closest('tr').remove();
});
</script>
<div class="box box-info">
<div class="box box-info collapsed-box">
<div class="box-header with-border">
<h3 class="box-title">Update Item Request From HD</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" style="font-size: 16px;" data-widget="collapse"><i
class="fa fa-plus"></i>
</button>
</div>
<!-- /.box-tools -->
</div>
<!-- /.box-header -->
<div class="box-body" style="display: block">
<form action="<?= site_url('item/editItemReqFromHD/'.$newMaster->update_stock_id) ?>" method="post">
<div class="row">
<div class="col-md-3">
<div class="form-group"><label>Request Date</label>
<input type="date" name="request_date" id="request_date" class="form-control" value="<?=$newMaster->billed_date?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group"><label>Select Product</label>
<select name="item" id="item" class="form-control select2" >
<option value="">Select Product</option>
<?php
if (!empty($products)) {
foreach ($products as $row) {
?>
<option value="<?= $row->item_id ?>"><?= $row->item_name ?></option>
<?php
}
}
?>
</select>
</div>
</div>
</div>
<!--table-->
<div class="col-md-12 column">
<div class="col-md-12">
<div class="control-group table-group">
<label class="table-label">Request Items *</label>
<div class="controls table-controls">
<table id="request_table"
class="table items table-striped table-bordered table-condensed table-hover">
<thead>
<tr style="background-color: #3c8dbc">
<th class="col-md-8">Product Name</th>
<th class="text-center" class="col-md-2">Quantity</th>
</th>
<th style="width: 30px !important; text-align: center;">
<i class="fa fa-trash-o" style="opacity:0.5; filter:alpha(opacity=50);"></i>
</th>
</tr>
</thead>
<tbody>
<?php
foreach ($itemReqFromHD as $row){
?>
<tr>
<td ><?=$row->item_name?>
<input type="hidden" id="item_id[]" name="item_id[]" value="<?=$row->item_id?>">
</td>
<td class="text-center"><input class="form-control" value="<?=$row->r_qty?>" required type="number" step="any" id="r_qty[<?=$row->item_id?>]" name="r_qty[<?=$row->item_id?>]" ></td>
<td class="text-center"><i class="fa fa-remove remove" style="cursor: pointer"></i></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8"></div>
<div class="col-md-4">
<button type="submit" class="btn btn-primary btn-block">Update Request</button>
</div>
</div>
</form>
</div>
</div>
</div>
All codes are working fine but at the time of the update the column 'r_qty' is not edited, leaving the table as follows:
Array
(
[0] => Array
(
[update_stock_id] => 577
[item] => 2
[r_qty] =>
[status] => 1
)
[1] => Array
(
[update_stock_id] => 577
[item] => 4
[r_qty] =>
[status] => 1
)
)
I could not catch what I am going wrong ? Can anyone help me ?

Bigcommerce Edit PayPal Button & Extend Link Area

We are using PayPal Express to quick checkout on the cart level. We would like to add "another" button that says PayPal Credit but has the same target with the original PayPal Express button. Extending clickable area of the first button would resolve the issue. Or could it be possible to make the 2nd button have the same target?
<script type="text/javascript">
lang.InvalidQuantity = "%%LNG_InvalidQuantity%%";
lang.Calculating = "%%LNG_Calculating%%"
lang.CalculateShipping = "%%LNG_CalculateShipping%%"
lang.ChooseShippingMethod = "%%LNG_ChooseShippingMethod%%"
lang.CartRemoveConfirm = '%%LNG_CartRemoveConfirm%%';
lang.ConfirmRemoveGiftWrapping = '%%LNG_ConfirmRemoveGiftWrapping%%';
lang.SelectCountry = '%%LNG_ChooseShippingCountry%%';
lang.SelectState = '%%LNG_ChooseShippingState%%';
lang.EnterZip = '%%LNG_EnterShippingZip%%';
</script>
<script src="%%GLOBAL_CdnAppPath%%/javascript/jquery/plugins/imodal/imodal.js?%%GLOBAL_JSCacheToken%%" type="text/javascript"></script>
<div class="Block Moveable Panel" id="CartContent_modified">
<div class="BlockContent">
<div style="display: %%GLOBAL_HideShoppingCartGrid%%" id="CartFormContainer">
<form enctype="multipart/form-data" onsubmit="return Cart.ValidateQuantityForm(this);" action="/cart.php" name="cartForm" id="cartForm" method="post">
<input type="hidden" name="action" value="update" />
<table class="CartContents Stylize General" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th class="HL-CartItems" colspan="2">%%LNG_CartItems%%</th>
<th class="HL-Qty">%%LNG_Qty%%</th>
<th class="HL-Remove"> </th>
<th class="HL-ItemPrice">%%LNG_ItemPrice%%</th>
<th class="HL-Total">%%LNG_HC_total%%</th>
</tr>
</thead>
<tfoot>
<tr class="SubTotal">
<td colspan="6"><div>%%LNG_Subtotal%% <em class="ProductPrice">%%GLOBAL_CartItemTotal%%</em></div></td>
</tr>
<tr class="SubTotal" style="%%GLOBAL_HideGiftWrappingTotal%%">
<td colspan="6"><div>%%LNG_GiftWrapping%% <em class="ProductPrice">%%GLOBAL_GiftWrappingTotal%%</em></div></td>
</tr>
%%SNIPPET_NormalCoupons%%
<tr class="SubTotal" style="%%GLOBAL_HideDiscountAmount%%">
<td colspan="6"><div>%%LNG_Discount%% <em class="ProductPrice">%%GLOBAL_DiscountAmount%%</em></div></td>
</tr>
<tr class="SubTotal" style="display:none;">
<td colspan="6" class="HL-ShoppingCartShippingEstimator">
<div>
<em>%%LNG_CalculateShippingHandling%%</em>
<div class="EstimateShipping" style="display: none;">
<div class="EstimatedShippingMethods" style="display: none;">
<div class="ShippingMethodList">
</div>
</div>
<dl class="hideThis">
<dt><span class="Required">*</span> %%LNG_Country%%:</dt>
<dd>
<select name="shippingZoneCountry" id="shippingZoneCountry" onchange="Cart.ToggleShippingEstimateCountry();">
%%GLOBAL_ShippingCountryList%%
</select>
</dd>
<dt><span class="Required" id="shippingZoneStateRequired">*</span> %%LNG_StateProvince%%:</dt>
<dd>
<select style="display: %%GLOBAL_ShippingHideStateList%%" name="shippingZoneState" id="shippingZoneState">
%%GLOBAL_ShippingStateList%%
</select>
<input style="display: %%GLOBAL_ShippingHideStateBox%%" type="text" class="Textbox" name="shippingZoneStateName" id="shippingZoneStateName" value="%%GLOBAL_AddressState%%" />
</dd>
<dt><span class="Required">*</span> %%LNG_ZipPostcode%%:</dt>
<dd><input type="text" class="Textbox" name="shippingZoneZip" id="shippingZoneZip" value="%%GLOBAL_ShippingZip%%" /></dd>
<!--dd class="Submit EstimateShippingButtons">
<input type="button" onclick="Cart.EstimateShipping();" value="%%LNG_CalculateShipping%%" class="btn alt" />
<div>%%LNG_Cancel%%</div>
</dd-->
</dl>
<p class="Submit EstimateShippingButtons">
<span>%%LNG_Cancel%% %%LNG_or%% </span><input type="button" onclick="Cart.EstimateShipping();" value="%%LNG_CalculateShipping%%" />
</p>
</div>
</div>
</td>
</tr>
<tr style="display:%%GLOBAL_HideShoppingCartShippingCost%%" class="SubTotal ShippingRow">
<td colspan="6"><div>%%LNG_Shipping%% (%%GLOBAL_ShippingProvider%%) <em class="ProductPrice">%%GLOBAL_ShippingCost%%</em></div></td>
</tr>
%%SNIPPET_FreeShippingCoupons%%
<tr style="display: %%GLOBAL_HideShoppingCartHandlingCost%%" class="SubTotal">
<td colspan="6"><div>%%LNG_Handling%% <em class="ProductPrice">%%GLOBAL_HandlingCost%%</em></div></td>
</tr>
%%GLOBAL_Taxes%%
%%SNIPPET_GiftCertificates%%
<tr class="SubTotal gtotal">
<td colspan="6"><div>%%LNG_GrandTotal%% <em class="ProductPrice">%%GLOBAL_CartTotal%%</em></div></td>
</tr>
%%GLOBAL_InclusiveTaxes%%
</tfoot>
<tbody>
%%SNIPPET_CartItems%%
</tbody>
</table>
<div class="KeepShopping">
Continue shopping
</div>
<div class="updateCart">
<input class="btn" type="submit" value="Update Cart" title="%%LNG_Update%%" />
</div>
</form>
<div class="ProceedToCheckout">
<!--div class="CheckoutButton" style="%%GLOBAL_HideCheckoutButton%%">
<a class="btn" href="%%GLOBAL_CheckoutLink%%" onclick="" title="%%LNG_CheckoutButtonTitle%%">%%LNG_HC_proceedcheckout%%</a>
</div-->
<div class="CheckoutButton" style="%%GLOBAL_HideCheckoutButton%%">
<a href="%%GLOBAL_CheckoutLink%%" onclick="%%GLOBAL_OptimizerLinkFunction%%" title="%%LNG_CheckoutButtonTitle%%">
%%GLOBAL_CartCheckoutButtonOptimizerScriptTag%%
<img src="https://cdn2.bigcommerce.com/server5400/vpslo31z/templates/__custom/images/blue/checkout.gif" alt="" />
%%GLOBAL_CartCheckoutButtonOptimizerNoScriptTag%%
</a>
</div>
<div class="AlternativeCheckout" style="%%GLOBAL_HideMultipleAddressShipping%%">
<p class="PTB20"><span style="%%GLOBAL_HideMultipleAddressShippingOr%%">-- %%LNG_or%% --</span><strong>%%LNG_CheckoutWithMultipleAddresses%%</strong></p>
</div>
%%GLOBAL_AdditionalCheckoutButtons%%
<div class="AlternativeCheckout">
<img src="https://www.paypalobjects.com/webstatic/en_US/i/buttons/ppcredit_MD_BNPOT_1x.png" alt="PayPal Credit" /> </div>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
<div style="display: %%GLOBAL_HideShoppingCartEmptyMessage%%">
<p class="InfoMessage">
%%LNG_NoItemsInCart%%
</p>
%%LNG_EmptyCartInfo%%
<br>
%%LNG_ContinueShopping%% %%LNG_OnThe%% %%GLOBAL_StoreName%% %%LNG_EmptyHomePage%%
</div>
</div>
</div>
<script type="text/javascript">
if (location.pathname !== '/checkout.php'){
$('.EstimateShippingLink').click();
$('#shippingZoneCountry').val(226);
$('#shippingZoneState').val(51);
$('#shippingZoneZip').val(19132);
/*
$('#shippingZoneCountry').change(function() {
$('#shippingZoneState').val(51);
$('#shippingZoneState').change(function(){
$('#shippingZoneZip').val(19132);
});
});*/
$('.Submit.EstimateShippingButtons > input').click();
$('.hideThis').hide();
$('.Submit.EstimateShippingButtons').hide();
}
$(document).ready(function(){
//var labelForFixedShipping= $("div.shippingquote label").filter(function() { return ($(this).text().trim() === "Fixed Shipping") });
//$("#shippingLabel").text($("#shippingLabel").text().replace("Fixed Shipping", "Your Shipping Cost"));
//alert($('#shippingLabel').html());
//alert(labelForFixedShipping);
//alert("Text");
//alert(labelForFixedShipping.text());
//labelForFixedShipping.text("Your Shipping Cost");
var ht = $("label[for = shippingLabel]").text();
//alert(ht);
});
</script>
<script type="text/javascript">
$(function() {
var cartSubtotal = parseFloat("%%GLOBAL_CartItemTotal%%".replace(/[$,]/g, ''));
if (cartSubtotal > 50) {
$("<a href='http:/yourdomain.com/cart.php?action=add&product_id=8122'></a>").click();
}
});
</script>
<script>
if (location.pathname !== '/checkout.php'){
$(document).ajaxComplete(function(){
sessionStorage.setItem('totals', $('table.CartContents>tfoot').html());
});
}
</script>

second page is not updating while using tr dir-paginate

I am using onaftersave() function to save the table data. In dir-paginate i am using ng-repeat to read the table row values. I kept itemsperpage is 5. obviously 6th row will be display in second Page. When I try to edit the second page row values it is not updating the second page rows. How to resolve it?
<form editable-form name="tableform1" oncancel="cancel()" onaftersave="saveTable(Manage_Role.Description)">
<div class="row">
<div class="col-xs-12">
<div class="panel panel-default panel-table">
<div class="panel-heading">
<div class="row">
<div class="col col-xs-6">
</div>
<div class="col col-xs-6 text-right">
<button type="button" data-toggle="modal" data-target="#myModal" class="btn btn-sm btn-primary btn-create" title="Add New Role">Add New Role</button>
</div>
</div>
</div>
<div class="panel-body scrollbar">
<table class="table table-striped table-bordered table-list">
<thead>
<tr>
<th style="width: 25%" align="center">
Name
</th>
<th style="width: 35%">
Description
</th>
<th style="width: 30% " align="center">
IsActive?
</th>
<th style="width: 10% " align="center"><a href="" ng-click="orderByField='IsActive';
reverseSort = !reverseSort" title="Assign">Assign</a></th>
<th style="width: 1%" align="center" ng-show="false">DirtyFlag</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="text" id="RoleNameID" ng-model="Manage_Role1.RoleName" placeholder="search" class="searchbox" onkeydown="return (event.keyCode!=13);"
/>
</td>
<td>
<input type="text" id="DescriptionID" ng-model="Manage_Role1.Description" placeholder="search" class="searchbox" onkeydown="return (event.keyCode!=13);"
/>
</td>
<td>
<select name="DropFilter" ng-model="Manage_Role1.IsActive" class="searchbox">
<option value="">All</option>
<option value=false>False</option>
<option value=true>True</option>
</select>
</td>
<!--<td></td>-->
</tr>
<tr dir-paginate="Manage_Role in Manage_Roleser | itemsPerPage:5 | filter:DropFilter | filter:Manage_Role1 | orderBy:orderByField:reverseSort "
ng-class-odd="'odd'">
<td ng-click="tableform1.$show()">
<span e-ng-change="applyHighlight($data,$index)" editable-text="Manage_Role.RoleName" ng-attr-title="{{Manage_Role.RoleName}}"
e-form="rowform" ng-click="rowform.$show()">
{{ Manage_Role.RoleName | uppercase }}
</span>
</td>
<td ng-click="tableform1.$show()">
<div>
<span e-ng-change="applyHighlight($data,$index)" editable-text="Manage_Role.Description" e-form="rowform" ng-attr-title="{{Manage_Role.Description}}"
ng-click="rowform.$show()">
{{ Manage_Role.Description || 'empty' }}
</span>
</div>
</td>
<td ng-click="tableform1.$show()" align="center">
<span e-ng-change="applyHighlight($data,$index)" ng-checked="Manage_Role.IsActive" editable-checkbox="Manage_Role.IsActive"
e-form="rowform" ng-click="applyHighlight($data,$index);tableform.$show()">
<input type="checkbox" ng-model="Manage_Role.IsActive" width="20" ng-attr-title="{{Manage_Role.IsActive}}" />
</span>
</td>
<td align="center">
<input type="image" data-toggle="modal" ng-click="Rolepopupclick(Manage_Role._id,Manage_Role.RoleName)" title="Assign UI"
data-target="#Div1" src="App_Themes/Images/AssignUser.png"
alt="Submit" width="28" height="28" />
</td>
<td ng-show="false">
<input type="text" ng-model="Manage_Role.DirtyFlag" ng-show="false" />
</td>
</tr>
</tbody>
</div>
</table>
</div>
<div class="panel-footer">
<div class="row">
<div class="col col-xs-8">
<dir-pagination-controls max-size="5" direction-links="true" boundary-links="true">
</dir-pagination-controls>
</div>
<div class="col col-xs-4">
<div class="btn-form" ng-show="tableform1.$visible" style="float:right">
<button type="submit" ng-disabled="tableform1.$waiting" title=" Save Changes" class="btn btn-primary fa fa-save" ng-click="NotifyClick()"> Save</button>
<input type="button" ng-disabled="tableform1.$waiting" title=" Close Edit Form Without Saving Changes" ng-click="refreshUI();tableform1.$cancel()"
class="btn btn-danger fa fa-close" value="X Cancel" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
controller code:
$scope.saveTable = function ()
{
debugger;
if(NotifyCount!=1){
var RoleNamechk = '';
for (var i = 0; i < $scope.Manage_Roleser.length; i++) {
RoleNamechk = $scope.Manage_Roleser[i].RoleName;
for (var j = 0; j < $scope.Manage_Roleser.length; j++) {
var RoleName = $scope.Manage_Roleser[j].RoleName;
if (RoleNamechk == RoleName) {
count++;
}
}
}
if (count == $scope.Manage_Roleser.length)
{
for (var i = 0; i < $scope.Manage_Roleser.length; i++) {
var id = $scope.Manage_Roleser[i]._id;
var rolename = $scope.Manage_Roleser[i].RoleName;
var isactive = $scope.Manage_Roleser[i].IsActive;
var description = $scope.Manage_Roleser[i].Description;
if (description == "")
{
description = 'empty';
}
if ($scope.Manage_Roleser[i].DirtyFlag == "True")
{
$scope.LoggedinUsers = $cookieStore.get('LoggedinUser');
var updatedBy= $scope.LoggedinUsers;
$http.put('/Roleupdate/' + id + '/' + rolename + '/' + isactive + '/' + description + '/' + updatedBy).then(function (response) {
refresh();
});
}
count=0;
}
$notify.success('Success', 'Role is Updated Successfully');
}
else {
$notify.warning('Warning', 'Role Name is Already Exists');
count = 0;
return '';
}
}
};
in ng-change I am checking dirty flag of selected index because it is updating all the row values. for that I am updating only selected($dirty) row alone. In second page it is not taking table index correctly. If I select 2nd page 3 row it will assume or taking index of the particular page. It should take index of selected row from the over all table row
$scope.applyHighlight = function ($data,index) {
$scope.Manage_Roleser[index].DirtyFlag = "True";
var dataSpan = $(event.currentTarget).closest('td');
if (!dataSpan.hasClass("highlighted")) {
$(dataSpan).addClass("highlighted");
}
}

expanding and collapsing table rows using angularjs ng-repeat -start and ng-repeat-end

i have one issue can anyone help me please...
i have a table in that table i have four users. and i have two icons(one is for expanding and another is for collapsing table rows data at time(all)) above table when i clicked on expand icon the data in table expanded and collapsed. so until this fine to me . now am going to expand particular row of table by clicking arrow(actually present in tr) it expanded particular row and collapsed that particular row. then this time if a clicked expand and collapse icons(expand all and collapse all). then expanding and collapsing are not working.
Here am using ng-repeat-start and ng-repeat-end.
<div class="comprehensiveINDiv" ng-show="visibleCarConferenceList">
<div class="top-bg-expand" >
<div class="col-md-5 color-blue">
<h1 class="main-heading1 ">Care Conference
<span class="expand-btns">
<a><i class="fa fa-compress color-blue" aria-hidden="true" ng-click="expanded = true"></i></a>
|
<a><i class="fa fa-expand" aria-hidden="true" ng-click="loadAllcareplans(); expanded = !expanded"></i></a>
</span>
</h1>
</div>
<div class="col-md-3 select-pan1 select-inner-pan1 careconfhed">
<label>Status: </label>
<select ng-model="filterOpt.opt"
ng-options="item.name for item in filterOpts.options"
ng-change="getCareConferenceList();resetPage();">
</select>
</div>
<div class="col-md-4 ">
<sm-range-picker-input class="margn0" fname="Range" label="Range"
form="test" ng-model="vm.rangeSelected" flex="100"
format="DD-MMM-YYYY" divider="To" week-start-day="Monday"
on-range-select="rangeSelected(range)"
ng-change="getCareConferenceList();">
</sm-range-picker-input>
</div>
</div>
<div ng-show="noConfData" class="margnL15">NO RECORDS FOUND</div>
<div>
<button type="button" class="btn btn-info btn-sm margnL15"
id="addnew_btn" ng-click="addNewconference();">ADD NEW</button>
</div>
<div ng-show="confGrid">
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-data3 tablestyle" id="tbl1">
<thead>
<tr>
<th></th>
<th> Date / Time </th>
<th>Reason</th>
<th>Status </th>
<th>Action</th>
<!--<th>time</th>-->
</tr>
</thead>
<tbody>
<tr ng-show="noConfData"><td colspan="4" >NO RECORDS FOUND</td></tr>
<tr ng-repeat-start="careconf in residentCareConferenceList" class="md-table-content-row class_{{careconf.CareConferenceID}}">
<td><a ng-click="expanded = !expanded"><i class="fa fa-angle-right" aria-hidden="true"></i></a></td>
<td ng-class="customClass[h.field]" class="md-table-content">{{careconf.CareConferenceDate | date:'dd/MM/yyyy hh:mm a'}}</td>
<td ng-class="customClass[h.field]" class="md-table-content">{{careconf.ReasonDescription}}</td>
<td ng-class="customClass[h.field]" class="md-table-content">{{careconf.careconferencestatus.CareConferenceStatusDescription}}</td>
<td><span class="fa fa-pencil" ng-click="EditCareConference(careconf.CareConferenceID);$event.stopPropagation();"></span></td>
<!--<td ng-class="customClass[h.field]" class="md-table-content">{{careconf.TotalTime}}</td>-->
</tr>
<tr ng-repeat-end ng-class="{'hide' : expanded}">
<td colspan="5" style="width: 100%; border:none !important; padding-left:20px;">
<div class="col-md-12 scrolldata">
<div class="col-md-12 ">
<div class="col-md-12 residance-data-text">
<p>Facility :{{careconf.facilitybase.FacilityName }}</p>
<p> Resident : {{currentResident.personbase.FullName}}</p>
<p> Admitted :{{currentResidentDetails.AdmitReAdmiDischDate | date:'dd/MM/yyyy hh:mm a'}}</p>
<p> Physician : {{residentprovider}}</p>
</div>
</div>
<div class="col-md-12" id="table">
<div class="col-md-12">
<!-- Table one -->
<p> Interdisciplinary team members involved in this Resident's Care Planning since last Care Conference ({{careconf.LastCareConferenceDate | date:'dd/MM/yyyy hh:mm a'}}) :</p>
<div class="tablestyledit">
<table class="table">
<tr>
<th width="50%" class="bdr-table">Name </th>
<th width="50%" class="bdr-table">Credentials </th>
</tr>
<tr ng-repeat="teamMember in careconf.teamMembers">
<td class="bdr-table">{{teamMember.ParticipantName}}</td>
<td class="bdr-table">{{teamMember.ParticipantRole}}</td>
</tr>
</table>
</div>
<div class="col-md-12" style="padding-top:0px;">
<div class="row">
<div class="md-form">
<p style="margin:0px;">Care Conference Summary</p>
<div class="empty-text">{{careconf.CareConferenceSummary}}</div>
</div>
</div>
</div>
<!--- /Table one -->
<!-- Table two -->
<div class="col-md-12" style="padding:0px;">
<p style="margin:0px; padding-top:10px;">Care Conference Participants :</p>
<div class="tablestyledit">
<table class="table ">
<tr>
<th width="50%" class="bdr-table">IDT Participant Name</th>
<th width="25%" class="bdr-table">Credentials</th>
<th width="25%" class="bdr-table">In Person</th>
</tr>
<tr ng-repeat="participant in careconf.participants">
<td class="bdr-table">{{participant.ParticipantName}}</td>
<td class="bdr-table">{{participant.ParticipantRole}}</td>
<td class="bdr-table">
<fieldset class="form-group">
<input type="checkbox" data-ng-model="participant.IsInPerson" disabled>
</fieldset>
</td>
</tr>
</table>
</div>
</div>
<!--/ Table two -->
<!-- Table three -->
<div class="col-md-12" style="padding:0px;">
<p style="margin:0px; padding-top:10px;">Family/Resident Attendance : </p>
<div class="tablestyledit">
<table class="table table-data-sub ">
<tr>
<th class="bdr-table">Name of person Invited</th>
<th class="bdr-table">Relationship</th>
<th class="bdr-table">Attended</th>
<th class="bdr-table">In Person</th>
</tr>
<tr ng-repeat="familyMember in careconf.familyMembers">
<td class="bdr-table">{{familyMember.ParticipantName}}</td>
<td class="bdr-table">{{familyMember.Relationship}}</td>
<td class="bdr-table">
<fieldset class="form-group">
<input type="checkbox" data-ng-model="familyMember.HasAttended" disabled>
</fieldset>
</td>
<td class="bdr-table">
<fieldset class="form-group">
<input type="checkbox" data-ng-model="familyMember.IsInPerson" disabled>
</fieldset>
</td>
</tr>
</table>
</div>
</div>
<div class="col-md-12" style="margin-left:-15px;margin-bottom:8px;">
<p> Care Conference Date : {{careconf.CareConferenceDate | date:'dd/MM/yyyy hh:mm a'}}</p>
<p>Signed by:</p>
</div>
</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<div flex layout="column" class="pagi-nation">
<div ng-show="confTotal > 1" flex layout="column">
<section layout="row" layout-padding="">
<div class="col-md-5 col-xs-12">Showing Page <strong>{{confPage}}</strong></div>
<div class="col-md-7 col-xs-12">
<cl-paging id="confPage" flex cl-pages="confTotal" , cl-steps="3" , cl-page-changed="loadConfPages.onPageChanged()" , cl-align="center center"
, cl-current-page="Paging.currentPage"></cl-paging>
</section>
</div>
</div>
</div>
</div>
</div>
</div>
<div ng-show="visibleCarConferenceAdd">
<div ng-include="'views/doctor/addCareConference.html'"></div>
</div>
</div>
and my controller code
$scope.loadAllcareplans = function () {
$scope.expanded = true;
}
and finally am so sorry for my stupid english. and check my functinality (expanded, $scope.loadAllcareplans() and icons at careconference foe expanding and collapsing all table data )
Check this fiddle
The content is not what you provided.
But the logic will be this
https://jsfiddle.net/athulnair/wkz5oq9z/
$scope.collapseAll = function() {
$scope.data.forEach(function(item) {
item.isCollapsed = false;
})
}
Rather than using the above ng-click function in the tag you could go with javascript and adding/removing classes dynamically.I have used ui-bootstrap and glyphicon. Follow the below code.
HTML:
<a data-toggle="collapse" data-target="#test"><i class="test_icon glyphicon glyphicon-collapse-down"></i><h4 class="header"> Test Class </h4></a>
JavaScript
$('#test').on('hidden.bs.collapse', function () {
$(".test_icon").removeClass("glyphicon-collapse-down").addClass("glyphicon-collapse-up");
});
$('#test').on('shown.bs.collapse', function () {
$(".test_icon").removeClass("glyphicon-collapse-up").addClass("glyphicon-collapse-down");
});