Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static FromJSON(json){
- let ctrl = new ScheduleControl2();
- let j = JSON.parse(json);
- for(let client of j.Data){
- let cC = ctrl.AddClientFromModel(client);
- ctrl._selectedClient = cC.dataset.id;
- for(let i = 0; i < 7; i++){
- for(let j = 0; j < 48; j++){
- let val = client.availability.data[i][j];
- if(val == 0){
- continue;
- }
- ctrl._addClientToShift(ctrl._selectedClient,i,j);
- }
- }
- }
- return ctrl;
- }
- ToJSON(){
- let data = {Data:[]};
- let clients = [];
- for(let client of this.ClientsElm.childNodes){
- client = client.childNodes[0];
- let c = {};
- c.name = client.dataset.name;
- c.address = client.dataset.address;
- c.shifts = parseInt(client.dataset.shifts);
- c.color = client.dataset.color;
- c.availability = {data:[[],[],[],[],[],[],[]]};
- for(let i = 0; i < 7; i++){
- for(let j = 0; j < 48; j++){
- c.availability.data[i][j] = 0;
- }
- }
- c._id = client.dataset.id;
- let shifts = this.Grid.querySelectorAll(`[data-id='${c._id}']`);
- for(let shift of shifts){
- c.availability.data[shift.dataset.day][shift.dataset.shift] = 1;
- }
- clients.push(c);
- }
- data.Data = clients;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement