Snippets
Created by
Gerald Bailey
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | Meteor.startup(function() {
GoogleMaps.load();
// Session.set("projectList", "[Home Depot POS]");
});
Template.body.helpers({
totalSites: function() {
return Sites.find().count();
},
completeSites: function() {
return Sites.find({
siteStatus: '1'
}).count();
},
problemSites: function() {
return Sites.find({
siteStatus: '2'
}).count();
}
});
// Template.body.events({
// "submit .filterBy-form": function (event) {
// // Prevent default browser form submit
// event.preventDefault();
//
// // Get value from form element
// var techName = event.target.text.value;
// console.log(event);
// console.log(techName);
// Session.set("techName", techName);
// // Clear form
// // event.target.text.value = "";
// }
// });
// Get Site Stats (1 = green, 2= yellow, 3 = red, 4 = complete)
Template.registerHelper('pickColor', function(inputNumber) {
inputNumber = parseInt(inputNumber);
switch (inputNumber) {
case 0:
return "black"; // Site not started yet.
break;
case 1: // Tech checked in.
return "green";
break;
// case 2:
// return "orange";
// break;
case 2: // Problem with site
return "red";
break;
}
});
// Get the selected sites to handle
$(document).ready(function() {
$("#handleSite").click(function() {
var siteIDs = $("#siteList input:checkbox:checked").map(function() {
return this.id;
}).get();
for (var i = 0; i < siteIDs.length; i++) {
Sites.update({ _id: siteIDs[i] }, {$set: { assignedTo: "Gerald"}});
}
$("#theSitesSelectAll").prop( "checked", false );
});
// Work with My Problem sites
$("#myProblemSites").click(function() {
var mySiteIDs = $("#mySites input:checkbox:checked").map(function() {
return this.id;
}).get();
for (var i = 0; i < mySiteIDs.length; i++) {
Sites.update({ _id: mySiteIDs[i] }, {$set: { assignedTo: null }});
}
$("#mySiteSelectAll").prop( "checked", false );
});
// Get the Selected Project Filters
$("#projectList").click(function() {
var projectList = $("#projectList input:checkbox:checked").map(function() {
return this.id;
}).get();
Session.set("projectList", projectList);
});
// Get the Selected Client Filters
$("#clientList").click(function() {
var clientList = $("#clientList input:checkbox:checked").map(function() {
return this.id;
}).get();
Session.set("clientList", clientList);
});
$('#sitesToShow input').on('change', function() {
Session.set("sitesToShow", $('input[name=sitesToShow]:checked', '#sitesToShow').val());
});
$("#filterPanelIcon").click(function() {
$("#filterPanel").toggle("slow");
});
$(".siteDetails").click(function() {
alert("Open Lightbox");
});
// $(".getSite").click(function() {
// alert("Open Lightbox");
// });
//
// $(".fancybox").fancybox({
// maxWidth : 800,
// maxHeight : 600,
// fitToView : false,
// width : '70%',
// height : '70%',
// autoSize : false,
// closeClick : false,
// openEffect : 'none',
// closeEffect : 'none'
// });
}); // End Document Ready
Template.getProjects.helpers({
sites: function() {
const projects = Template.instance().distinct.get();
// turn our array of project values into an array of {project: project}
return _.map(projects, project => {
return {
project
}
});
}
});
Template.getClients.helpers({
sites: function() {
const clients = Template.instance().distinct.get();
// turn our array of project values into an array of {project: project}
return _.map(clients, client => {
return {
client
}
});
}
});
Template.getProjects.onCreated(function() {
this.distinct = new ReactiveVar();
Meteor.call('getDistinctProjects', (error, result) => {
if (error) {
// do something
} else {
Session.set("projectList", result);
this.distinct.set(result); // save result when we get it
}
});
});
Template.getClients.onCreated(function() {
this.distinct = new ReactiveVar();
Meteor.call('getDistinctClients', (error, result) => {
if (error) {
// do something
} else {
Session.set("clientList", result);
this.distinct.set(result); // save result when we get it
}
});
});
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | <head>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="Gerald Bailey">
<link rel="icon" href="">
<!-- <link rel="stylesheet" href="/fancybox/jquery.fancybox.css" type="text/css" media="screen" /> -->
</head>
<body>
{{> header}}
<!-- {{#if isInRole 'super-admin'}} -->
<!-- Begin Site Body -->
<div class="container-fluid">
<!-- Start Filters Panel -->
<div class="panel panel-primary col-xs-2" id="filterPanel">
<div>
<ul class="list-unstyled">
<li class="text-right">Total Sites: {{totalSites}}</li>
<li class="text-success text-right">Sites Complete: {{completeSites}}</li>
<li class="text-warning text-right">Site Issues: {{problemSites}}</li>
</ul>
</div>
<hr>
<form class="filterBy-form">
<div class="form-group">
<label for="nameField">Filter By:</label>
<input type="text" name="text" class="form-control" id="siteField" placeholder="Site Name or Number" />
</div>
<div class="form-group">
<input type="email" name="text" class="form-control" id="techField" placeholder="Tech Name" />
</div>
<div class="form-group">
<table class="table table-condensed" id="projectList">
<thead>Project:</thead>
{{> getProjects}}
</table>
</div>
<div class="form-group">
<table class="table table-condensed" id="clientList">
<thead>Client:</thead>
{{> getClients}}
</table>
</div>
</form>
<hr>
<form class="form" id="sitesToShow">
<label for="nameField">Show:</label>
<div class="radio">
<label class="all-sites">
<input type="radio" name="sitesToShow" id="allSites" value="allSites" checked> All Sites
</label>
</div>
<div class="radio">
<label class="problem-sites">
<input type="radio" name="sitesToShow" id="problemSitesOnly" value="problemSitesOnly"> All Problem Sites
</label>
</div>
<div class="radio">
<label class="unassigned-sites">
<input type="radio" name="sitesToShow" id="problemSitesOnly" value="unassignedProblemSites"> Unassigned Problem Sites
</label>
</div>
</form>
</div>
<!-- End Filters Panel -->
<div>
<a href="#" id="filterPanelIcon">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
<!-- Map Panel -->
<div class="col-lg-10 col-md-10 col-sm-10">
<div class="row">
<div class="panel panel-primary">
{{> map}}
</div>
</div>
<div class="row">
{{> siteList}} {{> handleSites}}
</div>
<!-- End Row -->
</div>
{{> footer}}
</div>
<!-- {{/if}} -->
<!-- End Container -->
<!-- Latest compiled and minified JavaScript -->
</body>
<!-- Meteor Templates -->
<template name="getProjects">
{{#each sites}}
<div class="checkbox">
<label class="projectList">
<input type="checkbox" class="projectFilter" id="{{ project }}" checked="true">
<small>{{project}}</small>
</label>
</div>
{{/each}}
</template>
<template name="getClients">
{{#each sites}}
<div class="checkbox">
<label class="clientList">
<input type="checkbox" class="clientFilter" id="{{ client }}" checked="true">
<small>{{client}}</small>
</label>
</div>
{{/each}}
</template>
|
Comments (0)
You can clone a snippet to your computer for local editing. Learn more.