Best Python code snippet using yandex-tank
schedule_print.js
Source:schedule_print.js
1Ext.namespace('schedule_space');2schedule_space.schedule = function() {3 Ext.QuickTips.init();4 function querySchedule(_vType, _sch_gubun, _sDate, _eDate) {5 scheduleDataStore = new Ext.data.Store({6 proxy: new Ext.data.HttpProxy(7 new Ext.data.Connection({8 url: 'schedule.auth.do?method=aj_schedule_list',9 extraParams: { view_type : _vType,10 sch_gubun : _sch_gubun,11 start_date : _sDate,12 end_date : _eDate13 },14 method: 'POST'15 })16 ),17 reader: new Ext.data.XmlReader({18 record: 'Record',19 id: 'SCHEDULE_IDX',20 totalRecords: 'recCount'21 },22 ['SCHEDULE_IDX','USERS_IDX','USERS_NAME','DOMAIN','USER_GROUP_IDX','SCHEDULE_SHARE','SCHEDULE_TYPE',23 'SCHEDULE_TITLE','SCHEDULE_STMT','SCHEDULE_SDATE','SCHEDULE_EDATE','SCHEDULE_REPEAT','SCHEDULE_DAYLY','SCHEDULE_ALAM',24 'SCHEDULE_ALAM_DATE','SCHEDULE_ALAM_WAY','SCHEDULE_DDAY','SHARE_GROUP_IDX','REPEAT_WEEK','REPEAT_MONTH','REPEAT_YEAR']25 ),26 remoteSort: false,27 sortInfo:{field:'SCHEDULE_SDATE', direction:'ASC'},28 autoLoad: true,29 listeners:{30 load:function() {31 _calendar.draw();32// document.getElementById("span_dislay_month").innerHTML = _calendar.date.format('m') + "ì";33 self.print();34 }35 }36 });37 };38 function entryDraw(start, end) {39 var _entries = new Array();40 if (typeof scheduleDataStore != 'undefined' && scheduleDataStore.data.length> 0) {41 for(var ii=0; ii<scheduleDataStore.data.length; ii++ ) {42 id = scheduleDataStore.data.items[ii].data.SCHEDULE_IDX;43 category = schedule_type[scheduleDataStore.data.items[ii].data.SCHEDULE_TYPE];44 start = Calendar.str2date(scheduleDataStore.data.items[ii].data.SCHEDULE_SDATE);45 end = Calendar.str2date(scheduleDataStore.data.items[ii].data.SCHEDULE_EDATE);46 type = schdeule_idx_type[scheduleDataStore.data.items[ii].data.SCHEDULE_DAYLY];47 subject = scheduleDataStore.data.items[ii].data.SCHEDULE_TITLE;48 description = scheduleDataStore.data.items[ii].data.SCHEDULE_STMT;49 color = schedule_share_color[scheduleDataStore.data.items[ii].data.SCHEDULE_SHARE];50 bg = schedule_share_bgcolor[scheduleDataStore.data.items[ii].data.SCHEDULE_SHARE];51 icon = "";52 allowTag = true;53 userDate = "";54 _entries.push( new Calendar.Entry(id, category, start, end, type, "["+category+"]"+subject, description, color, bg, "", allowTag));55 }56 }57 _calendar.removeEntryAll();58 for(entry in _entries) {59 _calendar.addEntry(_entries[entry]);60 }61 };62 function entryMove(entry, start, end) {63 return true;64 };65 function entryClick(entry, x, y) {66 schedule_space.schedule_detail.openScheduleDetailWindow(entry.id, true);67 };68 function calendarClick(start, end) {69 //true를 리í´íë©´ ìí¸ë¦¬ê° ì´ëì´ ë¨, false를 리í´íë©´ ìí¸ë¦¬ ì´ëì´ ì·¨ìë¨70 if (start == null) {71 start = new Date();72 end = new Date();73 }74 schedule_space.schedule_regist.openScheduleRegistWindow(start, end);75 };76 function entryQuickAdd(start, end) {77 //alert('ã
ã
ã
ã
ì¼ì ì¶ê°');78 };79 function setEntries() {80 var id, category, start, end, type, subject, description, color, bg, icon, allowTag, userDate;81 _entries = new Array();82 for(var ii=0; ii<scheduleDataStore.data.length; ii++ ) {83 id = scheduleDataStore.data.items[ii].data.SCHEDULE_IDX;84 category = schedule_type[scheduleDataStore.data.items[ii].data.SCHEDULE_TYPE];85 start = scheduleDataStore.data.items[ii].data.SCHEDULE_SDATE;86 end = scheduleDataStore.data.items[ii].data.SCHEDULE_EDATE;87 type = schedule_type[scheduleDataStore.data.items[ii].data.SCHEDULE_TYPE];88 subject = scheduleDataStore.data.items[ii].data.SCHEDULE_TITLE;89 description = scheduleDataStore.data.items[ii].data.SCHEDULE_STMT;90 color = schedule_share_color[scheduleDataStore.data.items[ii].data.SCHEDULE_SHARE];91 bg = schedule_share_bgcolor[scheduleDataStore.data.items[ii].data.SCHEDULE_SHARE];92 icon = "";93 allowTag = true;94 userDate = "";95 _entries.push( new Calendar.Entry(id, category, start, end, type, subject, description, color, bg, "", allowTag));96 }97 };98 //ì¼ì 보기(ì¼,4ì¼,주,2주,ì)99 function viewScheduleList(_vType,divId_num) {100 var objForm = document.f_schedule_view;101 var _sDate;102 var _eDate;103 var view_arr = new Array();104 view_arr = ["ìê°","2주ê°","주ê°","4ì¼ê°","ì¼ê°"]105 for(i=0; i<5; i++){106 if( i == divId_num){107 document.getElementById("view_type_"+i).innerHTML = "<b>"+view_arr[i]+"</b>";108 }else{109 document.getElementById("view_type_"+i).innerHTML = view_arr[i];110 }111 }112 //calDate = _calendar.date.format('Y/m/d');113 //new Date(_date.replace(/\-/g,"/"));114 _sDate = getStartDate(_vType, _calendar.date);115 _eDate = getEndDate(_vType, _calendar.date);116 //ê²ìë²ìê° íì¬ë²ì ë²ì´ëê²½ì° ì¤ì¼ì¤ ì¡°í117 if (_sDate < _calendar.start || _eDate > _calendar.end ) {118 if (_vType != "month") {119 _sDate = _sDate.add(Date.DAY, -7);120 _eDate = _eDate.add(Date.DAY, 7);121 }122 //ì¤ì¼ì¤ ì¡°í123 querySchedule(_calendar.view, objForm.sch_gubun.value, _sDate.format('Y-m-d'), _eDate.format('Y-m-d'));124 }125 _calendar.changeView(_vType);126 //document.getElementById("span_dislay_month").innerHTML = _calendar.date.format('m') + "ì";127 };128 //ì¼ì ì´ë129 function moveScheduleList(_action) {130 var objForm = document.f_schedule_view;131 var _vType = _calendar.view;132 var _sDate, _eDate, _date;133 _date = _calendar.date;134 if (_action == 'prev') {135 if (_vType == "day" || _vType == "4day") {136 _date = _date.add(Date.DAY, -1);137 _sDate = getStartDate(_vType, _date);138 _eDate = getEndDate(_vType, _date);139 }else if (_vType == "week" || _vType == "2week") {140 _date = _date.add(Date.DAY, -7);141 _sDate = getStartDate(_vType, _date);142 _eDate = getEndDate(_vType, _date);143 }else if (_vType == "month") {144 _date = _date.add(Date.MONTH, -1);145 _sDate = getStartDate(_vType, _date);146 _eDate = getEndDate(_vType, _date);147 }148 if (_sDate < _calendar.start || _eDate > _calendar.end ) {149 //ì¤ì¼ì¤ ì¡°í150 if (_vType != "month") {151 _sDate = _sDate.add(Date.DAY, -7);152 _eDate = _eDate.add(Date.DAY, 7);153 }154 querySchedule(_calendar.view, objForm.sch_gubun.value, _sDate.format('Y-m-d'), _eDate.format('Y-m-d'));155 }156 _calendar.movePrev();157 } else if (_action == 'today') {158 _date = new Date();159 _sDate = getStartDate(_vType, _date);160 _eDate = getEndDate(_vType, _date);161 if (_sDate < _calendar.start || _eDate > _calendar.end ) {162 //ì¤ì¼ì¤ ì¡°í163 if (_vType != "month") {164 _sDate = _sDate.add(Date.DAY, -7);165 _eDate = _eDate.add(Date.DAY, 7);166 }167 querySchedule(_calendar.view, objForm.sch_gubun.value, _sDate.format('Y-m-d'), _eDate.format('Y-m-d'));168 }169 _calendar.moveToday();170 } else if (_action == 'next') {171 if (_vType == "day" || _vType == "4day") {172 _date = _date.add(Date.DAY, 1);173 _sDate = getStartDate(_vType, _date);174 _eDate = getEndDate(_vType, _date);175 }else if (_vType == "week" || _vType == "2week") {176 _date = _date.add(Date.DAY, 7);177 _sDate = getStartDate(_vType, _date);178 _eDate = getEndDate(_vType, _date);179 }else if (_vType == "month") {180 _date = _date.add(Date.MONTH, 1);181 _sDate = getStartDate(_vType, _date);182 _eDate = getEndDate(_vType, _date);183 }184 if (_sDate < _calendar.start || _eDate > _calendar.end ) {185 //ì¤ì¼ì¤ ì¡°í186 if (_vType != "month") {187 _sDate = _sDate.add(Date.DAY, -7);188 _eDate = _eDate.add(Date.DAY, 7);189 }190 querySchedule(_calendar.view, objForm.sch_gubun.value, _sDate.format('Y-m-d'), _eDate.format('Y-m-d'));191 }192 _calendar.moveNext();193 }194 document.getElementById("span_dislay_month").innerHTML = _calendar.date.format('m') + "ì";195 };196 function getStartDate(_type, _date) {197 if (_type == "day" || _type == "4day") {198 return _date;199 }else if (_type == "week") {200 return _date.add(Date.DAY, -_date.format('N'));201 }else if (_type == "2week") {202 return _date.add(Date.DAY, -_date.format('N'));203 }else if (_type == "month") {204 _date = _date.getFirstDateOfMonth();205 return _date.add(Date.DAY, -_date.format('N'));206 }207 };208 function getEndDate(_type, _date) {209 if (_type == "day") {210 return _date;211 }else if (_type == "4day") {212 return _date.add(Date.DAY, 3);213 }else if (_type == "week") {214 _date = _date.add(Date.DAY, -_date.format('N'));215 return _date.add(Date.DAY, 6);216 }else if (_type == "2week") {217 _date = _date.add(Date.DAY, -_date.format('N'));218 return _date.add(Date.DAY, 13);219 }else if (_type == "month") {220 _date = _date.getLastDateOfMonth();221 return _date.add(Date.DAY, (6 - _date.format('N')));222 }223 };224 function moveSchedule(_date) {225 var objForm = document.f_schedule_view;226 var _sDate, _eDate;227 if (_date < _calendar.start || _date > _calendar.end ) {228 //_sDate = _date.add(Date.DAY, -7);229 //_eDate = _date.add(Date.DAY, 7);230 _sDate = _date;231 _eDate = _date;232 //ì¤ì¼ì¤ ì¡°í233 querySchedule(_calendar.view, objForm.sch_gubun.value, _sDate.format('Y-m-d'), _eDate.format('Y-m-d'));234 }235 _calendar.changeView("day");236 document.getElementById("span_dislay_month").innerHTML = _calendar.date.format('m') + "ì";237 _calendar.go(_date.format('Y'), _date.format('m'), _date.format('d'));238 };239 function moveDailySchedule(_date) {240 moveSchedule(new Date(_date.substring(0,4), _date.substring(5,7)-1, _date.substring(8)));241 };242 function schedulePrint() {243 var schedule_print = window.open("schedule.auth.do?method=schedule_print" ,"schedule_print","status=no,toolbar=no,scroll=yes,resizable=yes,width=820,height=600");244 };245 function create_scheudle() {246 var objForm = document.f_schedule_view;247 Calendar.Language='ko';248 _calendar = new Calendar('div_schedule', 'month', (new Date()).format('Y-m-d'), false);249 _calendar.attachEvent('drawFinish', entryDraw); //ìºë¦°ëê° ê·¸ë ¤ì§ë©´ í¸ì¶í í¨ì, ì£¼ë¡ ìí¸ë¦¬ ì¶ê°ì ì¬ì©ëë¤250 _calendar.attachEvent('entryMove', entryMove); // ìí¸ë¦¬ë¥¼ ì´ëí ë í¸ì¶í í¨ì251 _calendar.attachEvent('entryClick', entryClick); // ìí¸ë¦¬ë¥¼ ì´ëí ë í¸ì¶í í¨ì252 _calendar.attachEvent('timeSelect', calendarClick); //253 _calendar.attachEvent('entryMenu', calendarClick);254 _calendar.draw();255 querySchedule(_calendar.view, objForm.sch_gubun.value, _calendar.start.format('Y-m-d'), _calendar.end.format('Y-m-d'));256 };257 function goScheduleView(sch_gubun) {258 querySchedule(_calendar.view, sch_gubun, _calendar.start.format('Y-m-d'), _calendar.end.format('Y-m-d'));259 };260 function scheduleBodyResize() {261 var div= document.getElementById('div_schedule');262 if (!div) return;263 //div.style.width= Ext.get(document.getElementById("div_schedule")).getWidth()-32+"px";264 //div.style.height= Ext.get(document.getElementById("div_schedule")).getHeight()-105+"px";265 if(_calendar !=null) _calendar.draw();266 };267 function reloadSchedule() {268 var objForm = document.f_schedule_view;269 schedule_space.schedule.querySchedule(_calendar.view, objForm.sch_gubun.value, _calendar.start.format('Y-m-d'), _calendar.end.format('Y-m-d'));270 left_schedule_space.left_schedule.leftScheduleReload();271 };272 return {273 moveSchedule: function(_date) {return moveSchedule(_date);},274 moveDailySchedule: function(_date) {return moveDailySchedule(_date);},275 moveScheduleList: function(_action) {return moveScheduleList(_action);},276 goScheduleView: function(sch_gubun) {return goScheduleView(sch_gubun);},277 schedulePrint: function() {return schedulePrint();},278 calendarClick: function() {return calendarClick();},279 viewScheduleList: function(_vType,_vType_num) {return viewScheduleList(_vType,_vType_num);},280 querySchedule: function(_vType, _sch_gubun, _sDate, _eDate) {return querySchedule(_vType, _sch_gubun, _sDate, _eDate);},281 reloadSchedule: function() {return reloadSchedule();},282 init: function() {283 //Ext.EventManager.onWindowResize(function(){ scheduleBodyResize(),false});284 //setTimeout(function(){285 create_scheudle();286 //_calendar.heigh = "100%";287 //scheduleBodyResize();288 //}, 100);289 }290 }291}();292schedule_space.schedule_regist = function() {293 var win_schedule_regist;294 var win_usergroup_tree;295 function openScheduleRegistWindow(startdt, enddt, winType) {296 var startdt_date, startdt_time, enddt_date, enddt_time;297 startdt_date = startdt.format('Y-m-d');298 enddt_date = enddt.format('Y-m-d');299 startdt_time = startdt.format('H:i');300 enddt_time = enddt.format('H:i');301 document.getElementById('schedule_pop_div').style.display ='none';302 document.getElementById('schedule_pop_div').style.display ='';303 clearForm(document.f_sr);304 document.getElementById("schedule_pop_div_title").innerHTML = "ì¼ì ë±ë¡";305 scheduleWriteInit(startdt_date,startdt_time,enddt_date,enddt_time);306 document.getElementById('schedule_pop_div_save_buttom').innerHTML = "<a href='javascript:schedule_space.schedule_regist.scheduleRegist();'><img src='/images/kor/btn/btnA_save.gif' /></a>";307//308 };309 function closeScheduleRegistWindow() {310 if (win_schedule_regist instanceof Ext.Window) {311 win_schedule_regist.close();312 }313 };314 function openUserGroupTree() {315 win_usergroup_tree = new Ext.Window({316 id:'kebi_ext_window_sd_tree',317 title:'ì¼ì ê´ë¦¬',318 colsable:true,319 width:630,320 plain:true,321 autoScroll:true,322 autoSize:true,323 closeAction:'close',324 items:new Ext.Panel({325 autoScroll: true,326 scripts:true,327 autoLoad:{328 url:'schedule.auth.do?method=schedule_regist_form',329 scripts:true330 }331 })332 });333 win_usergroup_tree.show();334 };335 function setRepeatDiv(startdt_date, enddt_date, startdt_time, enddt_time){336 var df1 = new Ext.form.DateField({337 id:'startdt_date_no',338 name:'startdt_date_no',339 format: 'Y-m-d',340 vtype: 'daterange',341 itemCls:'s_picker',342 readOnly :true,343 endDateField: 'enddt_date_no'344 })345 df1.render('norepeat_stdate');346 var df2 = new Ext.form.DateField({347 id:'enddt_date_no',348 name:'enddt_date_no',349 format: 'Y-m-d',350 vtype: 'daterange',351 readOnly :true,352 startDateField: 'startdt_date_no'353 })354 df2.render('norepeat_eddate');355 var df3 = new Ext.form.DateField({356 id:'startdt_date_re',357 name:'startdt_date_re',358 format: 'Y-m-d',359 vtype: 'daterange',360 readOnly :true,361 endDateField: 'enddt_date_re'362 })363 df3.render('repeat_stdate');364 var df4 = new Ext.form.DateField({365 id:'enddt_date_re',366 name:'enddt_date_re',367 format: 'Y-m-d',368 vtype: 'daterange',369 readOnly :true,370 startDateField: 'startdt_date_re'371 })372 df4.render('repeat_eddate');373 df1.setValue(startdt_date);374 df2.setValue(enddt_date);375 df3.setValue(startdt_date);376 df4.setValue(enddt_date);377 var tf1 =new Ext.form.TimeField({378 id:'startdt_time_no',379 name:'startdt_time_no',380 format: 'H:i',381 value: startdt_time,382 readOnly :true,383 endTimeField:'enddt_time_no',384 width:60385 })386 tf1.render('norepeat_sttime');387 var tf2 =new Ext.form.TimeField({388 id:'enddt_time_no',389 name:'enddt_time_no',390 format: 'H:i',391 value: enddt_time,392 readOnly :true,393 startTimeField:'startdt_time_no',394 width:60395 })396 tf2.render('norepeat_edtime');397 var tf3 =new Ext.form.TimeField({398 id:'startdt_time_re',399 name:'startdt_time_re',400 format: 'H:i',401 readOnly :true,402 value: startdt_time,403 width:50404 })405 tf3.render('repeat_sttime');406 var tf4 =new Ext.form.TimeField({407 id:'enddt_time_re',408 name:'enddt_time_re',409 format: 'H:i',410 readOnly :true,411 value: enddt_time,412 width:50413 })414 tf4.render('repeat_edtime');415 };416 function reSetRepeatDiv(){417 try{418 Ext.getCmp('startdt_date_no').destroy();419 Ext.getCmp('enddt_date_no').destroy();420 Ext.getCmp('startdt_date_re').destroy();421 Ext.getCmp('enddt_date_re').destroy();422 Ext.getCmp('startdt_time_no').destroy();423 Ext.getCmp('enddt_time_no').destroy();424 Ext.getCmp('startdt_time_re').destroy();425 Ext.getCmp('enddt_time_re').destroy();426 }catch(e){}427 };428 function onClickShareOpt(_type) {429 if(_type == 1) {430 document.getElementById("dv_share_group").style.display = 'block';431 } else {432 document.getElementById("dv_share_group").style.display = 'none';433 }434 };435 function CheckScheduleRepeat(_type) {436 if(_type == 0) {437 document.getElementById("div_sch_norepeat").style.display = 'block';438 document.getElementById("div_sch_repeat").style.display = 'none';439 } else {440 document.getElementById("div_sch_norepeat").style.display = 'none';441 document.getElementById("div_sch_repeat").style.display = 'block';442 }443 };444 //ì¼ì ë±ë¡445 function scheduleRegist() {446 var objForm = document.f_schedule_view;447 if(document.getElementById("SCHEDULE_TITLE").value=="") {448 alert("ì¼ì ì 목ì ì
ë ¥íì¸ì.");449 document.getElementById("SCHEDULE_TITLE").focus();450 return;451 } else if (document.getElementById("SCHEDULE_STMT").value == "") {452 alert("ì¼ì ë´ì©ì ì
ë ¥íì¸ì.");453 document.getElementById("SCHEDULE_STMT").focus();454 return;455 }456 if (document.getElementsByName("SCHEDULE_REPEAT")[0].checked) {457 if(document.getElementById("startdt_date_no") > document.getElementById("enddt_date_no")) {458 alert("ì¼ì ììì¼ì ì¢
ë£ì¼ë³´ë¤ ììì¼ í©ëë¤.");459 return;460 }461 if(document.getElementById("startdt_date_no") == document.getElementById("enddt_date_no")) {462 if(document.getElementById("startdt_time_no") == document.getElementById("enddt_time_no")) {463 alert("ì¼ì ìììê°ì ì¢
ë£ìê°ë³´ë¤ ììì¼ í©ëë¤.");464 return;465 }466 }467 } else if (!document.getElementsByName("SCHEDULE_REPEAT")[0].checked) {468 if(document.getElementById("startdt_date_re") > document.getElementById("enddt_date_re")) {469 alert("ì¼ì ììì¼ì ì¢
ë£ì¼ë³´ë¤ ììì¼ í©ëë¤.");470 return;471 }472 if(document.getElementById("startdt_date_re") == document.getElementById("enddt_date_re")) {473 if(document.getElementById("startdt_time_re") == document.getElementById("enddt_time_re")) {474 alert("ì¼ì ìììê°ì ì¢
ë£ìê°ë³´ë¤ ììì¼ í©ëë¤.");475 return;476 }477 }478 };479 //if (confirm("ì¼ì ì ë±ë¡ íìê² ìµëê¹?")) {480 Ext.Ajax.request({481 url:'schedule.auth.do?method=aj_schedule_regist',482 method:'POST',483 form: 'f_sr',484 success:function(response, opt){485 var reader = new Ext.data.XmlReader({486 record: 'RESPONSE'487 },488 ['RESULT','MESSAGE']);489 var resultXML = reader.read(response);490 if (resultXML.records[0].data.RESULT == "success") {491 closeDiv('schedule_pop_div');492 //closeScheduleRegistWindow();493 schedule_space.schedule.querySchedule(_calendar.view, objForm.sch_gubun.value, _calendar.start.format('Y-m-d'), _calendar.end.format('Y-m-d'));494 left_schedule_space.left_schedule.leftScheduleReload();495 } else {496 alert(resultXML.records[0].data.MESSAGE);497 }498 },499 failure:function(){500 alert('ë±ë¡ ì¤ë¥','ì¼ì ë±ë¡ì¤ ì¤ë¥ê° ë°ìíììµëë¤.\nê´ë¦¬ììê² ë¬¸ì íì기 ë°ëëë¤.')501 }502 });503 //}504 };505 function addMemorialDay() {506 schedule_space.schedule_regist.openScheduleRegistWindow(new Date(), new Date(), "M");507 };508 function addDDay() {509 schedule_space.schedule_regist.openScheduleRegistWindow(new Date(), new Date(), "D");510 };511 return {512 openScheduleRegistWindow: function(startdt, enddt, winType) {return openScheduleRegistWindow(startdt, enddt, winType);},513 setRepeatDiv: function(startdt_date, enddt_date, startdt_time, enddt_time) {return setRepeatDiv(startdt_date, enddt_date, startdt_time, enddt_time);},514 scheduleRegist: function() {return scheduleRegist();},515 closeScheduleRegistWindow: function() {return closeScheduleRegistWindow();},516 CheckScheduleAlam: function() {return CheckScheduleAlam();},517 CheckScheduleRepeat: function(_type) {return CheckScheduleRepeat(_type);},518 onClickShareOpt: function() {return onClickShareOpt();},519 addMemorialDay: function() {return addMemorialDay();},520 addDDay: function() {return addDDay();},521 reSetRepeatDiv:function() { return reSetRepeatDiv();}522 }523}();524schedule_space.schedule_detail = function() {525 var win_schedule_detail;526 function openScheduleDetailWindow(_schedule_idx, dummy_key) {527 Ext.Ajax.request({528 scope :this,529 url: 'schedule.auth.do?method=aj_schedule_info_by_xml',530 method : 'POST',531 params: {532 method:'schedule_info',533 SCHEDULE_IDX:_schedule_idx,534 dummy_key:dummy_key535 },536 success : function(response, options) {537 try {538 var reader = new Ext.data.XmlReader({record: 'RESPONSE'},['RESULT','MESSAGE',539 'SCHEDULE_IDX',540 'P_SCHEDULE_IDX',541 'USERS_IDX',542 'USERS_NAME',543 'DOMAIN',544 'USER_GROUP_IDX',545 'SCHEDULE_SHARE',546 'SHARE_GROUP_IDX',547 'SCHEDULE_TYPE',548 'SCHEDULE_TITLE',549 'SCHEDULE_STMT',550 'SCHEDULE_SDATE',551 'SCHEDULE_EDATE',552 'SCHEDULE_REPEAT',553 'SCHEDULE_DAYLY',554 'SCHEDULE_ALAM',555 'SCHEDULE_ALAM_DATE',556 'SCHEDULE_ALAM_WAY',557 'SCHEDULE_DDAY',558 'REPEAT_WEEK',559 'REPEAT_MONTH',560 'REPEAT_YEAR']);561 var resultXML = reader.read(response);562 if (resultXML.records[0].data.RESULT == "success") {563 document.getElementById("schedule_pop_div_title").innerHTML = "ì¼ì 보기 / ìì ";564 var startdt_date, startdt_time, enddt_date, enddt_time;565 startdt_date = resultXML.records[0].data.SCHEDULE_SDATE.substring(0, 10);566 enddt_date = resultXML.records[0].data.SCHEDULE_EDATE.substring(0, 10);567 startdt_time = resultXML.records[0].data.SCHEDULE_SDATE.substring(11, 16);568 enddt_time = resultXML.records[0].data.SCHEDULE_EDATE.substring(11, 16);569 document.getElementById('schedule_pop_div').style.display ='none';570 document.getElementById('schedule_pop_div').style.display ='';571 clearForm(document.f_sr);572 scheduleWriteInit(startdt_date,startdt_time,enddt_date,enddt_time);573 var objForm = document.f_sr;574 objForm.SCHEDULE_IDX.value= resultXML.records[0].data.SCHEDULE_IDX;575 objForm.SCHEDULE_TITLE.value = resultXML.records[0].data.SCHEDULE_TITLE;576 objForm.SCHEDULE_STMT.value = resultXML.records[0].data.SCHEDULE_STMT;577 setCheckedRadioByValue( document.f_sr.SCHEDULE_SHARE, resultXML.records[0].data.SCHEDULE_SHARE ); //ì¼ì 구ë¶578 setSelectedIndexByValue( document.f_sr.SCHEDULE_TYPE, resultXML.records[0].data.SCHEDULE_TYPE ); //ì¼ì ì¢
ë¥579 setCheckedRadioByValue( document.f_sr.SCHEDULE_REPEAT, resultXML.records[0].data.SCHEDULE_REPEAT ); //ì¼ì ë°ë³µ580 setCheckBoxByValue( document.f_sr.SCHEDULE_DAYLY_NO, resultXML.records[0].data.SCHEDULE_DAYLY_NO ); //ì¢
ì¼ì¼ì 581 setCheckBoxByValue( document.f_sr.SCHEDULE_DAYLY_RE, resultXML.records[0].data.SCHEDULE_DAYLY_RE ); //ì¢
ì¼ì¼ì 582 setSelectedIndexByValue( document.f_sr.SCHEDULE_ALAM, resultXML.records[0].data.SCHEDULE_ALAM ); //ì¼ì ì림583 setSelectedIndexByValue( document.f_sr.SHARE_GROUP_IDX, resultXML.records[0].data.SHARE_GROUP_IDX ); //그룹584 setCheckBoxByValue( document.f_sr.SCHEDULE_DDAY, resultXML.records[0].data.SCHEDULE_DDAY ); //D-DAY585 if( resultXML.records[0].data.USERS_IDX == objForm.USERS_IDX.value || isAdmin=="true"){586 document.getElementById('schedule_pop_div_save_buttom').innerHTML = "<a href='javascript:schedule_space.schedule_update.scheduleUpdate();'><img src='/images/kor/btn/btnA_save.gif' /></a> <a href='javascript:schedule_space.schedule_detail.ScheduleDelete("+resultXML.records[0].data.SCHEDULE_IDX+");'><img src='/images/kor/btn/btnA_delete2.gif' /></a>";587 }else{588 document.getElementById('schedule_pop_div_save_buttom').innerHTML = "";589 }590 if (resultXML.records[0].data.SCHEDULE_ALAM_WAY == "1") {591 document.f_sr.SCHEDULE_ALARM_WAY_MAIL.checked = true;592 } else if (resultXML.records[0].data.SCHEDULE_ALAM_WAY == "2") {593 document.f_sr.SCHEDULE_ALARM_WAY_MAIL.checked = false;594 } else if (resultXML.records[0].data.SCHEDULE_ALAM_WAY == "3") {595 document.f_sr.SCHEDULE_ALARM_WAY_MAIL.checked = true;596 }597 }598 } catch(e) {599 return ;600 }601 },602 failure : function(response, options) {603 }604 });605 }606 function closeScheduleDetailWindow() {607 if (win_schedule_detail instanceof Ext.Window) {608 win_schedule_detail.close();609 }610 };611 function ScheduleDelete(_schedule_idx) {612 var objForm = document.f_schedule_view;613 if (!confirm("ì¼ì ì ìì íìê² ìµëê¹.")) {614 return;615 }616 Ext.Ajax.request({617 url:'schedule.auth.do?method=aj_schedule_delete&SCHEDULE_IDX=' + _schedule_idx,618 method:'POST',619 success:function(response, opt){620 var reader = new Ext.data.XmlReader({621 record: 'RESPONSE'622 },623 ['RESULT','MESSAGE']);624 var resultXML = reader.read(response);625 if (resultXML.records[0].data.RESULT == "success") {626 closeDiv('schedule_pop_div');627 schedule_space.schedule.querySchedule(_calendar.view, objForm.sch_gubun.value, _calendar.start.format('Y-m-d'), _calendar.end.format('Y-m-d'));628 left_schedule_space.left_schedule.leftScheduleReload();629 } else {630 alert(resultXML.records[0].data.MESSAGE);631 }632 },633 failure:function(){634 alert('ìì ì¤ë¥','ì¼ì ìì ì¤ ì¤ë¥ê° ë°ìíììµëë¤.\nê´ë¦¬ììê² ë¬¸ì íì기 ë°ëëë¤.')635 }636 })637 };638 return {639 openScheduleDetailWindow:function(_schedule_idx, dummy_key) {return openScheduleDetailWindow(_schedule_idx, dummy_key);},640 closeScheduleDetailWindow:function() {return closeScheduleDetailWindow();},641 ScheduleDelete:function(_schedule_idx) {return ScheduleDelete(_schedule_idx);}642 }643}();644schedule_space.schedule_update = function() {645 var win_schedule_update;646 function openScheduleUpdateWindow(_schedule_idx) {647 schedule_space.schedule_detail.closeScheduleDetailWindow();648 win_schedule_update = new Ext.Window({649 id:'kebi_ext_window_sd_update',650 title:'ìì¸ì¼ì ìì ',651 colsable:true,652 width:630,653 plain:true,654 pageX:185,655 pageY:100,656 autoScroll:true,657 autoSize:true,658 closeAction:'close',659 items:new Ext.Panel({660 autoScroll: true,661 autoLoad:{662 url:'schedule.auth.do?method=schedule_update_form',663 params:{SCHEDULE_IDX:_schedule_idx},664 scripts:true665 }666 })667 });668 win_schedule_update.show();669 };670 function closeScheduleUpdateWindow() {671 if (win_schedule_update instanceof Ext.Window) {672 win_schedule_update.close();673 }674 };675 function scheduleUpdate() {676 var objForm = document.f_schedule_view;677 if(document.getElementById("SCHEDULE_TITLE").value=="") {678 alert("ì¼ì ì 목ì ì
ë ¥íì¸ì.");679 document.getElementById("SCHEDULE_TITLE").focus();680 return;681 } else if (document.getElementById("SCHEDULE_STMT").value == "") {682 alert("ì¼ì ë´ì©ì ì
ë ¥íì¸ì.");683 document.getElementById("SCHEDULE_STMT").focus();684 return;685 }686 if (document.getElementsByName("SCHEDULE_REPEAT")[0].checked) {687 if(document.getElementById("startdt_date_no") > document.getElementById("enddt_date_no")) {688 alert("ì¼ì ììì¼ì ì¢
ë£ì¼ë³´ë¤ ììì¼ í©ëë¤.");689 return;690 }691 if(document.getElementById("startdt_date_no") == document.getElementById("enddt_date_no")) {692 if(document.getElementById("startdt_time_no") == document.getElementById("enddt_time_no")) {693 alert("ì¼ì ìììê°ì ì¢
ë£ìê°ë³´ë¤ ììì¼ í©ëë¤.");694 return;695 }696 }697 } else if (!document.getElementsByName("SCHEDULE_REPEAT")[0].checked) {698 if(document.getElementById("startdt_date_re") > document.getElementById("enddt_date_re")) {699 alert("ì¼ì ììì¼ì ì¢
ë£ì¼ë³´ë¤ ììì¼ í©ëë¤.");700 return;701 }702 if(document.getElementById("startdt_date_re") == document.getElementById("enddt_date_re")) {703 if(document.getElementById("startdt_time_re") == document.getElementById("enddt_time_re")) {704 alert("ì¼ì ìììê°ì ì¢
ë£ìê°ë³´ë¤ ììì¼ í©ëë¤.");705 return;706 }707 }708 }709 Ext.Ajax.request({710 url:'schedule.auth.do?method=aj_schedule_update',711 method:'POST',712 form: 'f_sr',713 success:function(response, opt){714 var reader = new Ext.data.XmlReader({715 record: 'RESPONSE'716 },717 ['RESULT','MESSAGE']);718 var resultXML = reader.read(response);719 if (resultXML.records[0].data.RESULT == "success") {720 closeDiv('schedule_pop_div');721 schedule_space.schedule.querySchedule(_calendar.view, objForm.sch_gubun.value, _calendar.start.format('Y-m-d'), _calendar.end.format('Y-m-d'));722 left_schedule_space.left_schedule.leftScheduleReload();723 } else {724 alert(resultXML.records[0].data.MESSAGE);725 }726 },727 failure:function(){728 alert('ìì ì¤ë¥','ì¼ì ìì ì¤ ì¤ë¥ê° ë°ìíììµëë¤.\nê´ë¦¬ììê² ë¬¸ì íì기 ë°ëëë¤.')729 }730 });731 };732 return {733 openScheduleUpdateWindow:function(_schedule_idx) {return openScheduleUpdateWindow(_schedule_idx);},734 closeScheduleUpdateWindow:function() {return closeScheduleUpdateWindow();},735 scheduleUpdate:function() {return scheduleUpdate();}736 }737}();738Ext.onReady(schedule_space.schedule.init, schedule_space.schedule, true);739function closeDiv(obj){740 try{741 document.getElementById(obj).style.display ='none';742 }catch(e){}743}744function clearForm(obj){745 obj.reset();746}747function moveSchedule(_date) {748 var objForm = document.f_schedule_view;749 var _sDate, _eDate;750 if (_date < _calendar.start || _date > _calendar.end ) {751 //_sDate = _date.add(Date.DAY, -7);752 //_eDate = _date.add(Date.DAY, 7);753 _sDate = _date;754 _eDate = _date;755 //ì¤ì¼ì¤ ì¡°í756 querySchedule(_calendar.view, objForm.sch_gubun.value, _sDate.format('Y-m-d'), _eDate.format('Y-m-d'));757 }758 _calendar.changeView("day");759 document.getElementById("span_dislay_month").innerHTML = _calendar.date.format('m') + "ì";760 _calendar.go(_date.format('Y'), _date.format('m'), _date.format('d'));...
app-calendar.js
Source:app-calendar.js
1/*=========================================================================================2 File Name: toast-ui-calendar.js3 Description: toast-ui-calendar4 --------------------------------------------------------------------------------------5 Item Name: Frest HTML Admin Template6 Version: 1.07 Author: PIXINVENT8 Author URL: http://www.themeforest.net/user/pixinvent9==========================================================================================*/10'use strict';11(function (window, Calendar) {12 // variables13 var cal, resizeThrottled;14 var useCreationPopup = true;15 var useDetailPopup = true;16 // default keys and styles of calendar17 var themeConfig = {18 'common.border': '1px solid #DFE3E7',19 'common.backgroundColor': 'white',20 'common.holiday.color': '#FF5B5C',21 'common.saturday.color': '#304156',22 'common.dayname.color': '#304156',23 'month.dayname.borderLeft': '1px solid transparent',24 'month.dayname.fontSize': '1rem',25 'week.dayGridSchedule.borderRadius': '4px',26 'week.timegridSchedule.borderRadius': '4px',27 }28 // calendar initialize here29 cal = new Calendar('#calendar', {30 defaultView: 'month',31 useCreationPopup: useCreationPopup,32 useDetailPopup: useDetailPopup,33 calendars: CalendarList,34 theme: themeConfig,35 template: {36 milestone: function (model) {37 return '<span class="bx bx-flag align-middle"></span> <span style="background-color: ' + model.bgColor + '">' + model.title + '</span>';38 },39 allday: function (schedule) {40 return getTimeTemplate(schedule, true);41 },42 time: function (schedule) {43 return getTimeTemplate(schedule, false);44 }45 }46 });47 // calendar default on click event48 cal.on({49 'clickSchedule': function (e) {50 $(".tui-full-calendar-popup-top-line").css("background-color", e.calendar.color);51 $(".tui-full-calendar-calendar-dot").css("background-color", e.calendar.borderColor);52 },53 'beforeCreateSchedule': function (e) {54 // new schedule create and save55 saveNewSchedule(e);56 },57 'beforeUpdateSchedule': function (e) {58 // schedule update59 e.schedule.start = e.start;60 e.schedule.end = e.end;61 cal.updateSchedule(e.schedule.id, e.schedule.calendarId, e.schedule);62 },63 'beforeDeleteSchedule': function (e) {64 // schedule delete65 console.log('beforeDeleteSchedule', e);66 cal.deleteSchedule(e.schedule.id, e.schedule.calendarId);67 },68 'clickTimezonesCollapseBtn': function (timezonesCollapsed) {69 if (timezonesCollapsed) {70 cal.setTheme({71 'week.daygridLeft.width': '77px',72 'week.timegridLeft.width': '77px'73 });74 } else {75 cal.setTheme({76 'week.daygridLeft.width': '60px',77 'week.timegridLeft.width': '60px'78 });79 }80 return true;81 }82 });83 // Create Event according to their Template84 function getTimeTemplate(schedule, isAllDay) {85 var html = [];86 var start = moment(schedule.start.toUTCString());87 if (!isAllDay) {88 html.push('<span>' + start.format('HH:mm') + '</span> ');89 }90 if (schedule.isPrivate) {91 html.push('<span class="bx bxs-lock-alt font-size-small align-middle"></span>');92 html.push(' Private');93 } else {94 if (schedule.isReadOnly) {95 html.push('<span class="bx bx-block font-size-small align-middle"></span>');96 } else if (schedule.recurrenceRule) {97 html.push('<span class="bx bx-repeat font-size-small align-middle"></span>');98 } else if (schedule.attendees.length) {99 html.push('<span class="bx bxs-user font-size-small align-middle"></span>');100 } else if (schedule.location) {101 html.push('<span class="bx bxs-map font-size-small align-middle"></span>');102 }103 html.push(' ' + schedule.title);104 }105 return html.join('');106 }107 // A listener for click the menu108 function onClickMenu(e) {109 var target = $(e.target).closest('[role="menuitem"]')[0];110 var action = getDataAction(target);111 var options = cal.getOptions();112 var viewName = '';113 // on click of dropdown button change calendar view114 switch (action) {115 case 'toggle-daily':116 viewName = 'day';117 break;118 case 'toggle-weekly':119 viewName = 'week';120 break;121 case 'toggle-monthly':122 options.month.visibleWeeksCount = 0;123 options.month.isAlways6Week = false;124 viewName = 'month';125 break;126 case 'toggle-weeks2':127 options.month.visibleWeeksCount = 2;128 viewName = 'month';129 break;130 case 'toggle-weeks3':131 options.month.visibleWeeksCount = 3;132 viewName = 'month';133 break;134 case 'toggle-narrow-weekend':135 options.month.narrowWeekend = !options.month.narrowWeekend;136 options.week.narrowWeekend = !options.week.narrowWeekend;137 viewName = cal.getViewName();138 target.querySelector('input').checked = options.month.narrowWeekend;139 break;140 case 'toggle-start-day-1':141 options.month.startDayOfWeek = options.month.startDayOfWeek ? 0 : 1;142 options.week.startDayOfWeek = options.week.startDayOfWeek ? 0 : 1;143 viewName = cal.getViewName();144 target.querySelector('input').checked = options.month.startDayOfWeek;145 break;146 case 'toggle-workweek':147 options.month.workweek = !options.month.workweek;148 options.week.workweek = !options.week.workweek;149 viewName = cal.getViewName();150 target.querySelector('input').checked = !options.month.workweek;151 break;152 default:153 break;154 }155 cal.setOptions(options, true);156 cal.changeView(viewName, true);157 setDropdownCalendarType();158 setRenderRangeText();159 setSchedules();160 }161 // on click of next and previous button view change162 function onClickNavi(e) {163 var action = getDataAction(e.target);164 switch (action) {165 case 'move-prev':166 cal.prev();167 break;168 case 'move-next':169 cal.next();170 break;171 case 'move-today':172 cal.today();173 break;174 default:175 return;176 }177 setRenderRangeText();178 setSchedules();179 }180 // Click of new schedule button's open schedule create popup181 function createNewSchedule(event) {182 var start = event.start ? new Date(event.start.getTime()) : new Date();183 var end = event.end ? new Date(event.end.getTime()) : moment().add(1, 'hours').toDate();184 if (useCreationPopup) {185 cal.openCreationPopup({186 start: start,187 end: end188 });189 }190 }191 // new schedule create192 function saveNewSchedule(scheduleData) {193 var calendar = scheduleData.calendar || findCalendar(scheduleData.calendarId);194 var schedule = {195 id: String(chance.guid()),196 title: scheduleData.title,197 isAllDay: scheduleData.isAllDay,198 start: scheduleData.start,199 end: scheduleData.end,200 category: scheduleData.isAllDay ? 'allday' : 'time',201 dueDateClass: '',202 color: calendar.color,203 bgColor: calendar.bgColor,204 dragBgColor: calendar.bgColor,205 borderColor: calendar.borderColor,206 location: scheduleData.location,207 raw: {208 class: scheduleData.raw['class']209 },210 state: scheduleData.state211 };212 if (calendar) {213 schedule.calendarId = calendar.id;214 schedule.color = calendar.color;215 schedule.bgColor = calendar.bgColor;216 schedule.borderColor = calendar.borderColor;217 }218 cal.createSchedules([schedule]);219 refreshScheduleVisibility();220 }221 // view all checkbox initialize222 function onChangeCalendars(e) {223 var calendarId = e.target.value;224 var checked = e.target.checked;225 var viewAll = document.querySelector('.sidebar-calendars-item input');226 var calendarElements = Array.prototype.slice.call(document.querySelectorAll('#calendarList input'));227 var allCheckedCalendars = true;228 if (calendarId === 'all') {229 allCheckedCalendars = checked;230 calendarElements.forEach(function (input) {231 var span = input.parentNode;232 input.checked = checked;233 span.style.backgroundColor = checked ? span.style.borderColor : 'transparent';234 });235 CalendarList.forEach(function (calendar) {236 calendar.checked = checked;237 });238 } else {239 findCalendar(calendarId).checked = checked;240 allCheckedCalendars = calendarElements.every(function (input) {241 return input.checked;242 });243 if (allCheckedCalendars) {244 viewAll.checked = true;245 } else {246 viewAll.checked = false;247 }248 }249 refreshScheduleVisibility();250 }251 // schedule refresh according to view252 function refreshScheduleVisibility() {253 var calendarElements = Array.prototype.slice.call(document.querySelectorAll('#calendarList input'));254 CalendarList.forEach(function (calendar) {255 cal.toggleSchedules(calendar.id, !calendar.checked, false);256 });257 cal.render(true);258 calendarElements.forEach(function (input) {259 var span = input.nextElementSibling;260 span.style.backgroundColor = input.checked ? span.style.borderColor : 'transparent';261 });262 }263 // calendar type set on dropdown button264 function setDropdownCalendarType() {265 var calendarTypeName = document.getElementById('calendarTypeName');266 var calendarTypeIcon = document.getElementById('calendarTypeIcon');267 var options = cal.getOptions();268 var type = cal.getViewName();269 var iconClassName;270 if (type === 'day') {271 type = 'Daily';272 iconClassName = 'bx bx-calendar-alt mr-25';273 } else if (type === 'week') {274 type = 'Weekly';275 iconClassName = 'bx bx-calendar-event mr-25';276 } else if (options.month.visibleWeeksCount === 2) {277 type = '2 weeks';278 iconClassName = 'bx bx-calendar-check mr-25';279 } else if (options.month.visibleWeeksCount === 3) {280 type = '3 weeks';281 iconClassName = 'bx bx-calendar-check mr-25';282 } else {283 type = 'Monthly';284 iconClassName = 'bx bx-calendar mr-25';285 }286 calendarTypeName.innerHTML = type;287 calendarTypeIcon.className = iconClassName;288 }289 function setRenderRangeText() {290 var renderRange = document.getElementById('renderRange');291 var options = cal.getOptions();292 var viewName = cal.getViewName();293 var html = [];294 if (viewName === 'day') {295 html.push(moment(cal.getDate().getTime()).format('YYYY-MM-DD'));296 } else if (viewName === 'month' &&297 (!options.month.visibleWeeksCount || options.month.visibleWeeksCount > 4)) {298 html.push(moment(cal.getDate().getTime()).format('YYYY-MM'));299 } else {300 html.push(moment(cal.getDateRangeStart().getTime()).format('YYYY-MM-DD'));301 html.push('-');302 html.push(moment(cal.getDateRangeEnd().getTime()).format(' MM.DD'));303 }304 renderRange.innerHTML = html.join('');305 }306 // Randome Generated schedule307 function setSchedules() {308 cal.clear();309 generateSchedule(cal.getViewName(), cal.getDateRangeStart(), cal.getDateRangeEnd());310 cal.createSchedules(ScheduleList);311 refreshScheduleVisibility();312 }313 // Events initialize314 function setEventListener() {315 $('.menu-navigation').on('click', onClickNavi);316 $('.dropdown-menu [role="menuitem"]').on('click', onClickMenu);317 $('.sidebar-calendars').on('change', onChangeCalendars);318 $('.sidebar-new-schedule-btn').on('click', createNewSchedule);319 window.addEventListener('resize', resizeThrottled);320 }321 // get data-action atrribute's value322 function getDataAction(target) {323 return target.dataset ? target.dataset.action : target.getAttribute('data-action');324 }325 resizeThrottled = tui.util.throttle(function () {326 cal.render();327 }, 50);328 window.cal = cal;329 setDropdownCalendarType();330 setRenderRangeText();331 setSchedules();332 setEventListener();333})(window, tui.Calendar);334// set sidebar calendar list335(function () {336 var calendarList = document.getElementById('calendarList');337 var html = [];338 CalendarList.forEach(function (calendar) {339 html.push('<div class="sidebar-calendars-item"><label>' +340 '<input type="checkbox" class="tui-full-calendar-checkbox-round" value="' + calendar.id + '" checked>' +341 '<span style="border-color: ' + calendar.borderColor + '; background-color: ' + calendar.borderColor + ';"></span>' +342 '<span>' + calendar.name + '</span>' +343 '</label></div>'344 );345 });346 calendarList.innerHTML = html.join('\n');347})();348$(document).ready(function () {349 // calendar sidebar scrollbar350 if ($('.sidebar').length > 0) {351 var sidebar = new PerfectScrollbar(".sidebar", {352 wheelPropagation: false353 });354 }355 // sidebar menu toggle356 $(".sidebar-toggle-btn").on("click", function () {357 $(".sidebar").toggleClass("show");358 $(".app-content-overlay").toggleClass("show");359 })360 // on click Overlay hide sidebar and overlay361 $(".app-content-overlay, .sidebar-new-schedule-btn").on("click", function () {362 $(".sidebar").removeClass("show");363 $(".app-content-overlay").removeClass("show");364 });365})366$(window).on("resize", function () {367 // sidebar and overlay hide if screen resize368 if ($(window).width() < 991) {369 $(".sidebar").removeClass("show");370 $(".app-content-overlay").removeClass("show");371 }...
priceSchedules.js
Source:priceSchedules.js
1angular.module( 'orderCloud' )2 .config( PriceSchedulesConfig )3 .controller( 'PriceSchedulesCtrl', PriceSchedulesController )4 .controller( 'PriceScheduleEditCtrl', PriceScheduleEditController )5 .controller( 'PriceScheduleCreateCtrl', PriceScheduleCreateController )6;7function PriceSchedulesConfig( $stateProvider ) {8 $stateProvider9 .state( 'priceSchedules', {10 parent: 'base',11 url: '/priceSchedules?search&page&pageSize&sortBy&searchOn&filters',12 templateUrl:'priceSchedules/templates/priceSchedules.tpl.html',13 controller:'PriceSchedulesCtrl',14 controllerAs: 'priceSchedules',15 data: {componentName: 'Price Schedules'},16 resolve: {17 Parameters: function( $stateParams, OrderCloudParameters ) {18 return OrderCloudParameters.Get($stateParams);19 },20 PriceScheduleList: function( OrderCloud, Parameters ) {21 return OrderCloud.PriceSchedules.List(Parameters.search, Parameters.page, Parameters.pageSize || 12, Parameters.searchOn, Parameters.sortBy, Parameters.filters);22 }23 }24 })25 .state( 'priceSchedules.edit', {26 url: '/:priceScheduleid/edit',27 templateUrl:'priceSchedules/templates/priceScheduleEdit.tpl.html',28 controller:'PriceScheduleEditCtrl',29 controllerAs: 'priceScheduleEdit',30 resolve: {31 SelectedPriceSchedule: function($stateParams, OrderCloud) {32 return OrderCloud.PriceSchedules.Get($stateParams.priceScheduleid);33 }34 }35 })36 .state( 'priceSchedules.create', {37 url: '/create',38 templateUrl:'priceSchedules/templates/priceScheduleCreate.tpl.html',39 controller:'PriceScheduleCreateCtrl',40 controllerAs: 'priceScheduleCreate'41 })42}43function PriceSchedulesController($state, $ocMedia, PriceScheduleList, OrderCloudParameters, OrderCloud, Parameters ) {44 var vm = this;45 vm.list = PriceScheduleList;46 vm.parameters = Parameters;47 vm.sortSelection = Parameters.sortBy ? (Parameters.sortBy.indexOf('!') == 0 ? Parameters.sortBy.split('!')[1] : Parameters.sortBy) : null;48 //Check if filters are applied49 vm.filtersApplied = vm.parameters.filters || ($ocMedia('max-width:767px') && vm.sortSelection); //Sort by is a filter on mobile devices50 vm.showFilters = vm.filtersApplied;51 //Check if search was used52 vm.searchResults = Parameters.search && Parameters.search.length > 0;53 //Reload the state with new parameters54 vm.filter = function(resetPage) {55 $state.go('.', OrderCloudParameters.Create(vm.parameters, resetPage));56 };57 //Reload the state with new search parameter & reset the page58 vm.search = function() {59 vm.filter(true);60 };61 //Clear the search parameter, reload the state & reset the page62 vm.clearSearch = function() {63 vm.parameters.search = null;64 vm.filter(true);65 };66 //Clear relevant filters, reload the state & reset the page67 vm.clearFilters = function() {68 vm.parameters.filters = null;69 $ocMedia('max-width:767px') ? vm.parameters.sortBy = null : angular.noop(); //Clear out sort by on mobile devices70 vm.filter(true);71 };72 //Conditionally set, reverse, remove the sortBy parameter & reload the state73 vm.updateSort = function(value) {74 value ? angular.noop() : value = vm.sortSelection;75 switch(vm.parameters.sortBy) {76 case value:77 vm.parameters.sortBy = '!' + value;78 break;79 case '!' + value:80 vm.parameters.sortBy = null;81 break82 default:83 vm.parameters.sortBy = value;84 }85 vm.filter(false);86 };87 //Used on mobile devices88 vm.reverseSort = function() {89 Parameters.sortBy.indexOf('!') == 0 ? vm.parameters.sortBy = Parameters.sortBy.split('!')[1] : vm.parameters.sortBy = '!' + Parameters.sortBy;90 vm.filter(false);91 };92 //Reload the state with the incremented page parameter93 vm.pageChanged = function() {94 $state.go('.', {page:vm.list.Meta.Page});95 };96 //Load the next page of results with all of the same parameters97 vm.loadMore = function() {98 return OrderCloud.PriceSchedules.List(Parameters.search, vm.list.Meta.Page + 1, Parameters.pageSize || vm.list.Meta.PageSize, Parameters.searchOn, Parameters.sortBy, Parameters.filters)99 .then(function(data) {100 vm.list.Items = vm.list.Items.concat(data.Items);101 vm.list.Meta = data.Meta;102 });103 };104}105function PriceScheduleEditController($scope, $exceptionHandler, $state, OrderCloud, SelectedPriceSchedule, PriceBreak, toastr ) {106 var vm = this,107 priceScheduleid = angular.copy(SelectedPriceSchedule.ID);108 vm.priceScheduleName = angular.copy(SelectedPriceSchedule.Name);109 vm.priceSchedule = SelectedPriceSchedule;110 vm.priceSchedule.MinQuantity =1;111 vm.addPriceBreak = function() {112 PriceBreak.addPriceBreak(vm.priceSchedule, vm.price, vm.quantity);113 vm.quantity = null;114 vm.price = null;115 };116 PriceBreak.addDisplayQuantity(vm.priceSchedule);117 vm.deletePriceBreak = PriceBreak.deletePriceBreak;118 vm.Submit = function() {119 vm.priceSchedule = PriceBreak.setMinMax(vm.priceSchedule);120 OrderCloud.PriceSchedules.Update(priceScheduleid, vm.priceSchedule)121 .then(function() {122 $state.go('priceSchedules', {}, {reload:true});123 toastr.success('Price Schedule Updated', 'Success');124 })125 .catch(function(ex) {126 $exceptionHandler(ex)127 });128 };129 vm.Delete = function() {130 OrderCloud.PriceSchedules.Delete(priceScheduleid)131 .then(function() {132 $state.go('priceSchedules', {}, {reload:true});133 toastr.success('Price Schedule Deleted', 'Success');134 })135 .catch(function(ex) {136 $exceptionHandler(ex)137 });138 };139 $scope.$watch(function() {140 return vm.priceSchedule.RestrictedQuantity;141 },function(value){142 if(vm.priceSchedule.RestrictedQuantity == true){143 vm.priceHeader = "Total Price";144 }else{145 vm.priceHeader = "Price Per Unit";146 }147 });148}149function PriceScheduleCreateController($scope, $exceptionHandler, $state, OrderCloud, PriceBreak,toastr) {150 var vm = this;151 vm.priceSchedule = {};152 vm.priceSchedule.RestrictedQuantity = false;153 vm.priceSchedule.PriceBreaks = new Array();154 vm.priceSchedule.MinQuantity =1;155 vm.priceSchedule.OrderType = 'Standard';156 vm.addPriceBreak = function() {157 PriceBreak.addPriceBreak(vm.priceSchedule, vm.price, vm.quantity);158 vm.quantity = null;159 vm.price = null;160 };161 vm.deletePriceBreak = PriceBreak.deletePriceBreak;162 vm.Submit = function() {163 vm.priceSchedule = PriceBreak.setMinMax(vm.priceSchedule);164 OrderCloud.PriceSchedules.Create(vm.priceSchedule)165 .then(function() {166 $state.go('priceSchedules', {}, {reload:true});167 toastr.success('Price Schedule Created', 'Success')168 })169 .catch(function(ex) {170 $exceptionHandler(ex)171 });172 }173 $scope.$watch(function() {174 return vm.priceSchedule.RestrictedQuantity;175 },function(value){176 if(vm.priceSchedule.RestrictedQuantity == true){177 vm.priceHeader = "Total Price";178 }else{179 vm.priceHeader = "Price Per Unit";180 }181 });...
priceSchedules.spec.js
Source:priceSchedules.spec.js
1describe('Component: PriceSchedules', function() {2 var scope,3 q,4 priceSchedule,5 oc;6 beforeEach(module('orderCloud'));7 beforeEach(module('orderCloud.sdk'));8 beforeEach(inject(function($q, $rootScope,OrderCloud) {9 q = $q;10 scope = $rootScope.$new();11 priceSchedule = {12 ID: "TestPriceSchedule123456789",13 Name: "TestPriceSchedule123456789",14 ApplyTax: true,15 ApplyShipping: false,16 MinQuantity: null,17 MaxQuantity: null,18 UseCumulativeQuantity: false,19 RestrictedQuantity: false,20 OrderType: "Standard",21 PriceBreaks: [22 {23 Quantity: 1,24 Price: 5.025 }26 ]27 };28 oc = OrderCloud;29 }));30 describe('State: priceSchedules', function() {31 var state;32 beforeEach(inject(function($state) {33 state = $state.get('priceSchedules');34 spyOn(oc.PriceSchedules, 'List').and.returnValue(null);35 }));36 it('should resolve PriceScheduleList', inject(function ($injector) {37 $injector.invoke(state.resolve.PriceScheduleList);38 expect(oc.PriceSchedules.List).toHaveBeenCalled();39 }));40 });41 describe('State: priceSchedules.edit', function() {42 var state;43 beforeEach(inject(function($state) {44 state = $state.get('priceSchedules.edit');45 spyOn(oc.PriceSchedules, 'Get').and.returnValue(null);46 }));47 it('should resolve SelectedPriceSchedule', inject(function ($injector, $stateParams) {48 $injector.invoke(state.resolve.SelectedPriceSchedule);49 expect(oc.PriceSchedules.Get).toHaveBeenCalledWith($stateParams.priceScheduleid);50 }));51 });52 describe('Controller: PriceScheduleEditCtrl', function() {53 var priceScheduleEditCtrl;54 beforeEach(inject(function($state, $controller) {55 priceScheduleEditCtrl = $controller('PriceScheduleEditCtrl', {56 $scope: scope,57 SelectedPriceSchedule: priceSchedule58 });59 spyOn($state, 'go').and.returnValue(true);60 }));61 describe('addPriceBreak', function() {62 var quantity;63 var price;64 beforeEach(inject(function(PriceBreak) {65 priceScheduleEditCtrl.priceSchedule = priceSchedule;66 priceScheduleEditCtrl.quantity = quantity;67 priceScheduleEditCtrl.quantity = price;68 spyOn(PriceBreak, 'addPriceBreak').and.returnValue(null);69 priceScheduleEditCtrl.addPriceBreak();70 }));71 it ('should call the PriceBreak addPriceBreak method', inject(function(PriceBreak) {72 expect(PriceBreak.addPriceBreak).toHaveBeenCalledWith(priceSchedule, price, quantity);73 }));74 });75 describe('Submit', function() {76 beforeEach(function() {77 priceScheduleEditCtrl.priceSchedule = priceSchedule;78 priceScheduleEditCtrl.priceScheduleID = "TestPriceSchedule123456789";79 var defer = q.defer();80 defer.resolve(priceSchedule);81 spyOn(oc.PriceSchedules, 'Update').and.returnValue(defer.promise);82 priceScheduleEditCtrl.Submit();83 scope.$digest();84 });85 it ('should call the PriceSchedules Update method', function() {86 expect(oc.PriceSchedules.Update).toHaveBeenCalledWith(priceScheduleEditCtrl.priceScheduleID, priceScheduleEditCtrl.priceSchedule);87 });88 it ('should enter the priceSchedules state', inject(function($state) {89 expect($state.go).toHaveBeenCalledWith('priceSchedules', {}, {reload:true});90 }));91 });92 describe('Delete', function() {93 beforeEach(function() {94 var defer = q.defer();95 defer.resolve(priceSchedule);96 spyOn(oc.PriceSchedules, 'Delete').and.returnValue(defer.promise);97 priceScheduleEditCtrl.Delete();98 scope.$digest();99 });100 it ('should call the PriceSchedules Delete method', function() {101 expect(oc.PriceSchedules.Delete).toHaveBeenCalledWith(priceSchedule.ID);102 });103 it ('should enter the priceSchedules state', inject(function($state) {104 expect($state.go).toHaveBeenCalledWith('priceSchedules', {}, {reload:true});105 }));106 });107 });108 describe('Controller: PriceScheduleCreateCtrl', function() {109 var priceScheduleCreateCtrl;110 beforeEach(inject(function($state, $controller) {111 priceScheduleCreateCtrl = $controller('PriceScheduleCreateCtrl', {112 $scope: scope113 });114 spyOn($state, 'go').and.returnValue(true);115 }));116 describe('addPriceBreak', function() {117 var quantity;118 var price;119 beforeEach(inject(function(PriceBreak) {120 priceScheduleCreateCtrl.priceSchedule = priceSchedule;121 priceScheduleCreateCtrl.quantity = quantity;122 priceScheduleCreateCtrl.quantity = price;123 spyOn(PriceBreak, 'addPriceBreak').and.returnValue(null);124 priceScheduleCreateCtrl.addPriceBreak();125 }));126 it ('should call the PriceBreak addPriceBreak method', inject(function(PriceBreak) {127 expect(PriceBreak.addPriceBreak).toHaveBeenCalledWith(priceSchedule, price, quantity);128 }));129 });130 describe('Submit', function() {131 beforeEach(function() {132 priceScheduleCreateCtrl.priceSchedule = priceSchedule;133 var defer = q.defer();134 defer.resolve(priceSchedule);135 spyOn(oc.PriceSchedules, 'Create').and.returnValue(defer.promise);136 priceScheduleCreateCtrl.Submit();137 scope.$digest();138 });139 it ('should call the PriceSchedules Create method', function() {140 expect(oc.PriceSchedules.Create).toHaveBeenCalledWith(priceSchedule);141 });142 it ('should enter the priceSchedules state', inject(function($state) {143 expect($state.go).toHaveBeenCalledWith('priceSchedules', {}, {reload:true});144 }));145 });146 });...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!