Modal dialog angular js
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2016 10:24 PM
Hi All,
I am trying to change "approval info" widget as user's can reject the requests without providing comments in service portal.
So, i thought to display a model dialog to ask for the comments and send these comments back to the server to update in the record. I am struggling to get this done. Please help me to acheive this.
HTML template:
<div class="panel panel-{{::c.options.color}} b">
<div class="panel-heading">
<h4 class="panel-title" ng-if="c.data.state == 'requested'">${This {{c.data.label}} requires your approval}</h4>
<h4 class="panel-title" ng-if="c.data.state == 'approved'">${Approved} <sn-time-ago timestamp="::c.data.sys_updated_on" /></h4>
<h4 class="panel-title" ng-if="c.data.state == 'rejected'">${Rejected} <sn-time-ago timestamp="::c.data.sys_updated_on" /></h4>
</div>
<div class="panel-body">
<form ng-submit="$event.preventDefault()" class="form-horizontal">
<div ng-if="c.data.fields.length > 0">
<div ng-repeat="field in c.data.fields" class="m-b-xs" ng-if="field.value">
<label class="m-n">{{field.label}}</label>
<span ng-switch="field.type">
<div ng-switch-when="glide_date_time" title="{{field.display_value}}"><sn-time-ago timestamp="::field.value" /></div>
<div ng-switch-default >{{field.display_value}}</div>
</span>
</div>
</div>
<div ng-if="c.data.state == 'requested'" class="question">
<button type="button" name="approve" class="btn btn-success btn-question" ng-click="c.action('approved')">${Approve}</button>
<div class="spacer"></div>
<button type="button" name="reject" class="btn btn-default btn-question" ng-click="c.action('rejected')">${Reject}</button>
<input ng-model="myInput" class="demo">
</div>
</form>
</div>
Client controller:
function ($scope, $uibModal) {
var c = this;
c.action = function(state) {
c.modalInstance = $uibModal.open({
templateUrl: 'modalTemplate',
scope: $scope
});
c.closeModal = function() {
c.modalInstance.close();
}
c.okay = function() {
$modalInstance.close();
c.data.op = state;
c.data.state = state;
if(state == 'rejected')
{
c.data.comments = c.data.sometext;
}
c.server.update();
}
}
}
Server script:
var gr = $sp.getRecord();
if (input && input.op && gr) {
gr.state = input.op;
gr.update();
}
var fields = $sp.getFields(gr, 'state,sys_created_on');
if (gr) {
if (gr.sys_mod_count > 0)
fields.push($sp.getField(gr, 'sys_updated_on'));
data.fields = fields;
data.state = gr.state.toString();
data.sys_updated_on = gr.sys_updated_on.toString();
data.sys_id = gr.getUniqueValue();
data.table = gr.getTableName();
data.label = getRecordBeingApproved(gr).getLabel();
data.input = input.myInput;
data.comments = gr.comments;
}
function getRecordBeingApproved(gr) {
if (!gr.sysapproval.nil())
return gr.sysapproval.getRefRecord();
return gr.document_id.getRefRecord();
}
Thanks and regards
Swamy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2017 01:47 PM
If you submit the form again with a comment does the second time show the first times notes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2017 10:14 PM
Hi Andrews,
Yes, the comment field is not getting cleared.
Regards
Swamy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2017 06:34 AM
did you find a solution we are running into a VERY similiar issue... the log notes what happened one click before.. so the first time it is undefined .. the second click shows the results from the first etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2017 06:36 AM
we used $uibModal instead of spModal