Skip to content

Instantly share code, notes, and snippets.

@wave-inguane
Last active September 1, 2021 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wave-inguane/791811bfd37742e7de1b2bfac1964bfd to your computer and use it in GitHub Desktop.
Save wave-inguane/791811bfd37742e7de1b2bfac1964bfd to your computer and use it in GitHub Desktop.
spModal
/*******************************************************************************************************************************
* Start Custom Popup Model
*******************************************************************************************************************************/
//..................................................................................................................
STEP 1: HTML Template
//..................................................................................................................
<script type="text/ng-template" id="modalTemplate">
<div class="panel">
<div class="panel-body wrapper-xl">
<div style="font-weight: bold; color:#254B70;">
<center>
iDevOps LLC ServiceNow Labs
</center>
</div>
<br>
<div style="font-weight: bold; color:#800000;">
<center>
NOTICE TO ALL USERS
</center>
</div>
<br>
<div style="color:#202020;">
<div>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
standard dummy text ever since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting,
remaining essentially unchanged. It was popularised in the 1960s with
</div>
<br>
<div>
the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<br>
<div>
the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus
PageMaker including versions of Lorem Ipsum.
</div>
<br>
<div>
the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<ul>
<br>
<li>
the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus
PageMaker including versions of Lorem Ipsum.
</li>
<li>
At the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like
Aldus PageMaker including versions of Lorem Ipsum.
</li>
<li>
The the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software
like Aldus PageMaker including versions of Lorem Ipsum.
</li>
<li>
You the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software
like Aldus PageMaker including versions of Lorem Ipsum.
</li>
</ul>
</div>
</div>
<div class="panel-footer text-right">
<button class="btn btn-primary" ng-click="c.closeModal()">${Accept}</button>
<button class="btn btn-primary" ng-click="c.rejectWarning()">${Reject}</button>
</div>
</div>
</script>
//..................................................................................................................
STEP 2: Client Script
//..................................................................................................................
api.controller=function($uibModal, $scope,$location) {
/* widget controller */
var c = this;
c.openModal = function() {
c.modalInstance = $uibModal.open({
templateUrl: 'modalTemplate',
scope: $scope,
backdrop: 'static'
});
}
c.closeModal = function() { //Accepted
c.data.status = true;
c.server.update();
c.modalInstance.close();
}
c.rejectWarning = function() {//Rejected
c.data.status = false;
c.server.update();
$location.url("/sp");
}
//alert(c.data.checkUp);
if(c.data.checkUp)
c.openModal();
};
//..................................................................................................................
STEP 3: Server Script
//..................................................................................................................
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
var userId = gs.getUserID();
/*
if(input){
var grx = new GlideRecord('u_tracker_record');
grx.addQuery('u_user_targeted',userId)
grx.query();
if(grx.next()){
if(input.status){
grx.u_security_record_log += gs.now()+' '+gs.getUserDisplayName()+' '+options.accept_phrase+' \n';
grx.u_last_checked_in = gs.now();
}else{
grx.u_security_record_log += gs.now()+' '+gs.getUserDisplayName()+' '+options.reject_phrase+' \n';
}
grx.update();
}
}*/
/*
var checkSecurity = function(id){
var gr = new GlideRecord('u_tracker_record');
gr.addQuery('u_user_targeted',id)
gr.query();
if(gr.next()){
var lastUpdate = gr.u_last_checked_in;
var gd = new GlideDate();
var today = gd.getByFormat("yyyy-MM-dd");
if(today==lastUpdate){
return false;
}else{
return true;
}
}else{
var grCreate = new GlideRecord('u_tracker_record');
grCreate.initialize();
grCreate.u_user_targeted = id;
grCreate.u_security_record_log = options.start_log +' '+ gs.now()+'\n';
grCreate.insert();
return true;
}
}*/
data.checkUp = true;
//data.checkUp = checkSecurity(userId);
})();
/*******************************************************************************************************************************
* End Custom Popup Model
*******************************************************************************************************************************/
// HTML template
<button ng-click="c.onAlert()" class="btn btn-default">
Alert
</button>
// Client script
function(spModal) {
var c = this;
c.onAlert = function () {
spModal.alert('How do you feel today?').then(function (answer) {
c.simple = answer;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment