I will select the images in one page and show those selected 5 images in other page.the selected images will be stored in selected array initially, before sending put request to server. In showing page, i had one button called change picture ,i am sending put request to server after selecting 5 images in selecting image page,that will be stored in an array called other_media.if i click change picture button it will redirect to selecting image page.(again the selected array will be empty) in selecting image page, those images which are already selected to be shown at right side[means i need to push the data in other_media array to selected array] of the result in plunker. i need exactly showing the images which are already selected(posted or put) the plunker is only one page which i select the images.
Plunker https://plnkr.co/edit/BM4AavLn9uKxKL4wdbT6?p=preview
<div class="row">
<div class="col-xs-6 col-sm-5 col-md-5">
<h3 style="text-align: center;text-shadow: 0px 4px 6px;">All Pictures</h3>
<div class="row" ng-repeat="media in pinMedia">
<!-- pin.media_id!=media._id || -->
<div class="col-xs-12 col-sm-12 col-md-5">
<img ng-src="http://placehold.it/{{images}}" width="200px" />
<p>{{media.Name}}</p>
<div class="col-xs-12 col-sm-12 col-md-5">
<button ng-disabled='limit()' class="btn btn-success" style="border: .0625rem solid transparent;padding: .465rem 1rem;" ng-click="toselected(media)">
<i class="fa fa-picture-o"></i>
Set Picture</button >
</div>
</div>
</div>
</div>
<div class="col-xs-6 col-sm-5 col-md-5">
<h3 style="text-align: center;text-shadow: 0px 4px 6px;">Selected Pictures</h3>
<div ng-repeat="media in selected">
<!-- pin.media_id==media._id && -->
<div>
<img ng-src="http://placehold.it/{{images}}" width="200px" />
<p>{{media.Name}}</p>
<div>
<a class="btn btn-success " style="border: .0625rem solid transparent;padding: .465rem 1rem;" ng-click="tosource(media)">
<i class="fa fa-picture-o"></i>
Remove Picture</a>
</div>
</div>
</div>
</div>
</div>
<!--I have id in my work. but here we don't have id. i need to save particular object in an selected array to another array -->
<button ng-click="setMediaForCurrentPin(selected)" class="btn btn-success" style="margin:50px auto; display:table;">Submit</button>
Javascript
$scope.selected = [];
FromOne2Another = function(source, target, item) {
target.push(item);
source.splice(source.indexOf(item), 1);
}
//this is the starting of code where i send the selected pitures from unselected before put request.
$scope.toselected = function(item) {
FromOne2Another($scope.pinMedia, $scope.selected, item);
}
$scope.tosource = function(item) {
FromOne2Another($scope.selected, $scope.pinMedia, item);
}
//this is the ending of above code
//From here i am trying to get the data from the stored media
$scope.toSelectedArray=function(item){
FromOne2Another($scope.other_media, $scope.selected, item);
console.log($scope.pins);
}
If i use like this inside service, why i am getting Cannot read property 'splice' of undefined
one my website video to understand https://nimbus.everhelper.me/client/notes/share/376595/vyEMbEoxsFIfN3X39T5tLdbD8aGfxAgF
Related
I have implemented Pagination and Search in AngularJS but its working in only on displayed page.
Html file
<div id="home" class="tab-pane fade in active">
<div class="row"><div class="col-md-10"><h1 style="font-size: 25px;margin-bottom:26px;">Jobs</h1></div></div>
<div class="row">
<div class="col-md-0"></div>
<div class="col-md-10" style="margin-top:5px">
<div class="container">
<li style="list-style-type: none;display: inline-block;width: 85%;"> <form name="myForm" action="/action_page.php" method="get" class="adjust" style="margin-left:-26px;margin-top:2px;">
<input type="text" name="Keyword" placeholder="Keyword" class="borderclr" ng-model='search.jobTitle' style="border: 1px solid #ddd;padding: 10px;width: 48%;margin-left:5px;">
<input type="text" name="Location" placeholder="Location"class="borderclr" ng-model='search.location' style="border: 1px solid #ddd;padding: 10px;width: 50%;">
</form>
</li>
<li style="list-style-type: none;display: inline-block;">
<i class="fa fa-plus" title="Add Job" ng-click="openJobModal('add')" data-toggle="modal" data-target="#jobDetails"
style="margin-top: 33px; color: rgb(237,78,110);cursor: pointer;font-size: 22px;margin-left: -140px;outline:none;"></i>
</li>
</div>
<div class= row>
<div class="col-md-10"></div>
<div class="col-md-2"></div>
</div>
<div ng-repeat="Job in JobDetails.slice(((currentPage-1)*itemsPerPage), ((currentPage)*itemsPerPage)) | filter:search:strict">
<!-- <p style="font-size: 13px;color: #808080;padding: 18px;margin-left: 49px;">Found 395 Jobs</p> -->
<h3 style="font-size: 18px;color: #000;font-weight: 600;margin-top: 2px;margin-left: -4px;text-align:left;margin-bottom: -7px;">
Title : {{Job.jobTitle}}</h3>
<div class="row" style="margin-left:1px;">
<div class="col-md-8" style="margin-left: -16px;margin-top:6px"> <b> {{Job.location}} | {{Job.jobRate}} | {{Job.jobType}}</b></div>
<div class="col-md-1"><i class="fa fa-eye" title="View Job" ng-click="Jobview(Job.SerialNumber)" data-toggle="modal" data-target="#jobDetails" style="margin-top:10px;cursor: pointer;color : rgb(237,78,110);font-size:22px;outline:none;"></i></div>
<div class="col-md-1"><i class="fa fa-trash" title="Delete Job" ng-click="JobDelete(Job.SerialNumber,Job.Publish)" style="margin-top:10px;cursor: pointer;color : rgb(237,78,110);font-size:22px;outline:none;"></i></div>
<div class="col-md-2"><button style="padding: 6px 22px;" ng-click="jobPublish('true',Job.SerialNumber)" type="button" ng-hide="{{Job.Publish}}" class="btn btn-success">Publish</button>
<button type="button" ng-click="jobPublish('false',Job.SerialNumber)" ng-show="{{Job.Publish}}" class="btn btn-warning">UnPublish</button>
</div>
</div>
<p style=" text-align: justify;text-justify: inter-word;">
<b>Description :</b>{{Job.jobDescription | limitTo: 400 }}{{Job.jobDescription.length > 400 ? '...' : ''}}</p>
<hr>
</div>
</div>
</div>
<div ng-show="JobDetails !=''" style="text-align: right;">
<pagination total-items="JobDetails.length" ng-model="currentPage" ng-change="pageChanged()" max-size="maxSize" class="pagination-sm" boundary-links="true" items-per-page="itemsPerPage"></pagination>
</div>
</div>
Script
$scope.JobDetails = [];
for(var i=response.data.length-1;i>=0;i--){
$scope.JobDetails.push(response.data[i]);
}
$scope.viewby = 5;
$scope.totalItems = $scope.JobDetails.length;
$scope.currentPage = 1;
$scope.itemsPerPage = $scope.viewby;
$scope.maxSize = 7; //Number of pager buttons to show
When i use search box and search , the results are only for that page . If we remove the pagination the search is working fine.
Can some one please help.
your search filter is applied to currant page items only therefore you get only filtered item that exist in this page.
you can do the following to solve the problem:
<div ng-repeat="Job in currentJobDetails | filter:search:strict">
in your pageChanged() function you can add:
function pageChanged(){
currentJobDetails = JobDetails.slice(((currentPage-1)*itemsPerPage), ((currentPage)*itemsPerPage));
}
you may also need to add search button and call function when is clicked:
function search(){
currentJobDetails = JobDetails;
}
this will search across all your items
I am trying to automate a site in which I get numbers of records and I want to find a record which contains a particular text and then click on the button corresponding to that record. Problem I am facing is that I can find the text but the button is in another div. Can anyone help?
Below is the html:
<div class="row">
<div class="col-lg-3 col-md-3 col-sm-3">
<div class="col-lg-5 col-md-5 col-sm-5">
<p class="f-12 ng-binding">
<!-- ngIf: item.childCategoryName.length>0 -->
<p class="f-13 black-text ng-binding ng-scope" ng-if="item.childCategoryName.length>0">
<!-- end ngIf: item.childCategoryName.length>0 -->
<p class="f-13 black-text">
<p class="f-13 black-text">
<h3 id="content" class="s-job ng-binding">test47</h3>
<p id="content" class="f-12 m-t-20 ng-binding">test47 </p>
</div>
<div class="col-sm-4 col-md-4 col-lg-4 ">
<div class="pull-right">
<p class="">
<button id="121" class="btn btn-green" ng-click="jobInfo(item.taskId)">
<span class="pull-left ng-binding">Voir la tâche</span>
<span class="circle"/>
</button>
</div>
</div>
</div>
<hr/>
</div>
Try below and let me know the result:
driver.findElement(By.xpath("//h3[.='" + title + "']/following::button[.='Voir la tâche']")).click()
You can also add some explicit wait for element to present in DOM:
WebDriverWait wait = new WebDriverWait(driver,20);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//h3[.='" + title + "']/following::button[.='Voir la tâche']"))).click();
or check if your button located inside an iframe
I have 2 columns, first column is Unselected images and button called Select picture next to it and second column is selected images and button called Remove picture. if i click Select picture button for one image at left column, it should move to right side column and it should disappear in left side column.
Viceversa for the remove picture. if i click remove picture at right, it should disappear at right and should appear at left.I should be able to select and remove multiple pictures. i have used angular js. Can anyone please help me
Plunker here https://plnkr.co/edit/rtJP91MtYISyVZkdFWr8?p=preview
<body ng-controller="myController">
<div class="row">
<div class="col-xs-6 col-sm-5 col-md-5">
<h3 style="text-align: center;text-shadow: 0px 4px 6px;">All Pictures</h3>
<div class="row" ng-repeat="media in pinMedia" ng-init="setMedia=[]">
<!-- pin.media_id!=media._id || -->
<div ng-show="!setMedia[$index]" class="col-xs-12 col-sm-12 col-md-5">
<img ng-src="http://placehold.it/{{images}}" width="200px">
<div class="col-xs-12 col-sm-12 col-md-5">
<a class="btn btn-success" style="border: .0625rem solid transparent;padding: .465rem 1rem;" ng-click="setMedia[$index]=false"><i class="fa fa-picture-o"></i> Set Picture</a>
</div>
</div>
</div>
</div>
<div class="col-xs-6 col-sm-5 col-md-5">
<h3 style="text-align: center;text-shadow: 0px 4px 6px;">Selected Pictures</h3>
<div ng-repeat="media in pinMedia">
<!-- pin.media_id==media._id && -->
<div ng-show="setMedia[$index]">
<img ng-src="http://placehold.it/{{images}}" width="200px">
<div>
<a class="btn btn-success " style="border: .0625rem solid transparent;padding: .465rem 1rem;" ng-click="removeMediaForCurrentPin(media)"><i class="fa fa-picture-o"></i> Remove Picture</a>
</div>
</div>
</div>
</div>
</div>
I corrected your Plunker, please look at new example.
HTML:
<body ng-controller="myController">
<div class="row">
<div class="col-xs-6 col-sm-5 col-md-5">
<h3 style="text-align: center;text-shadow: 0px 4px 6px;">All Pictures</h3>
<div class="row" ng-repeat="media in pinMedia">
<!-- pin.media_id!=media._id || -->
<div class="col-xs-12 col-sm-12 col-md-5">
<img ng-src="http://placehold.it/{{images}}" width="200px" />
<p>{{media.Name}}</p>
<div class="col-xs-12 col-sm-12 col-md-5">
<button ng-disabled='limit()' class="btn btn-success" style="border: .0625rem solid transparent;padding: .465rem 1rem;" ng-click="toselected(media)">
<i class="fa fa-picture-o"></i>
Set Picture</button >
</div>
</div>
</div>
</div>
<div class="col-xs-6 col-sm-5 col-md-5">
<h3 style="text-align: center;text-shadow: 0px 4px 6px;">Selected Pictures</h3>
<div ng-repeat="media in selected">
<!-- pin.media_id==media._id && -->
<div>
<img ng-src="http://placehold.it/{{images}}" width="200px" />
<p>{{media.Name}}</p>
<div>
<a class="btn btn-success " style="border: .0625rem solid transparent;padding: .465rem 1rem;" ng-click="tosource(media)">
<i class="fa fa-picture-o"></i>
Remove Picture</a>
</div>
</div>
</div>
</div>
</div>
</body>
Javascript:
var newapp = angular.module('angularApp', []);
newapp.controller('myController',function($scope){
$scope.pinMedia=[
{Name:'130x130'},
{Name:'150x150'},
{Name:'170x170'},
{Name:'180x180'},
{Name:'190x190'},
{Name:'200x200'},
{Name:'210x210'}
];
$scope.selected=[];
FromOne2Another = function(source, target, item){
target.push(item);
source.splice(source.indexOf(item),1);
}
$scope.toselected = function(item){
FromOne2Another($scope.pinMedia, $scope.selected, item);
}
$scope.tosource = function(item){
FromOne2Another($scope.selected, $scope.pinMedia, item);
}
$scope.limit=function(){
return 5==$scope.selected.length;
}
});
Initially there will be set of images at left and right. if i click set image on left side. it will be moved to right side. right side column will show the selected pictures, left side column shows unselected pictures. i will be able to select 5 pictures at a time and submit it. if i click submit button those 5 images will be shown in another page,post request will be sent to server.there will be one button in that page called change picture button. if i click that , i need already selected images to be shown at another page of right hand side column.
Here is the plunker link https://plnkr.co/edit/BM4AavLn9uKxKL4wdbT6?p=preview
<body ng-controller="myController">
<div class="row">
<div class="col-xs-6 col-sm-5 col-md-5">
<h3 style="text-align: center;text-shadow: 0px 4px 6px;">All Pictures</h3>
<div class="row" ng-repeat="media in pinMedia">
<!-- pin.media_id!=media._id || -->
<div class="col-xs-12 col-sm-12 col-md-5">
<img ng-src="http://placehold.it/{{images}}" width="200px" />
<p>{{media.Name}}</p>
<div class="col-xs-12 col-sm-12 col-md-5">
<button ng-disabled='limit()' class="btn btn-success" style="border: .0625rem solid transparent;padding: .465rem 1rem;" ng-click="toselected(media)">
<i class="fa fa-picture-o"></i>
Set Picture</button >
</div>
</div>
</div>
</div>
<div class="col-xs-6 col-sm-5 col-md-5">
<h3 style="text-align: center;text-shadow: 0px 4px 6px;">Selected Pictures</h3>
<div ng-repeat="media in selected">
<!-- pin.media_id==media._id && -->
<div>
<img ng-src="http://placehold.it/{{images}}" width="200px" />
<p>{{media.Name}}</p>
<div>
<a class="btn btn-success " style="border: .0625rem solid transparent;padding: .465rem 1rem;" ng-click="tosource(media)">
<i class="fa fa-picture-o"></i>
Remove Picture</a>
</div>
</div>
</div>
</div>
<button ng-click="setMediaForCurrentPin(selected)" class="btn btn-success" style="margin:50px auto; display:table;">Submit</button>
</div>
Seems like modals in Angular UI is difficult to update, previously in Bootstrap I could update via jQuery but in Angular UI, not able to do even a simple update.
I have <span id="spnApproveSelectedCount">0</span> inside my modal-body, and I update it using jQuery $('#spnApproveSelectedCount').text(selectedCount); like this. It was working in Bootstrap but not in Angular UI.
Even update from $scope is not working if that variable is inside the modal. But if I moved them outside of modal it is working. I suspect it is because the modal is not display yet?
Updated:
I have a repeat in which the each item is clickable. When user clicked on it, it's supposed to open up the modal with further info. Below are my codes.
<div class="list-group">
<div ng-repeat="approval in approvals" class="list-group-item">
<div class="row">
<div class="selectable" style="float: left; width: 95%" ui-turn-on="detailsModal" ng-click="SetDetails(approval)">
<p class="list-group-item-text"><b>Ref</b> <span>{{ approval.ref }}</span></p>
<p class="list-group-item-text"><b>Pay To</b> <span>{{ approval.payTo }}</span></p>
<p class="list-group-item-text"><b>From</b> <span>{{ approval.from }}</span></p>
</div>
</div>
</div>
</div>
Notice that I have the ng-click on the row and below are my codes at controller.
$scope.SetDetails = function(current)
{
$scope.details = current;
}
And also partial of my modal code..
<div class="modal" ui-if="detailsModal" ui-state='detailsModal'>
<div class="modal-backdrop in"></div>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" ui-turn-off="detailsModal">×</button>
<h4 class="modal-title">Transaction Details</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-5">
Type
</div>
<div class="col-sm-7">
<b>{{ details.category }}</b>
</div>
</div>
<br />
<div class="row">
<div class="col-sm-5">
Submitted By
</div>
<div class="col-sm-7">
<b>{{ details.submittedBy }}</b>
</div>
</div>
Before everything, in fact in my controller I have a line of code to pre-set the details variable to take the first element (before it is passed to ng-repeat), this works and when the modal open, it is showing the first element value and that's it, the value stays there even if I click on row 2, 3 ...
$scope.details = $scope.approvals[0];