Fixed change owner, and other display issues
This commit is contained in:
parent
379f903507
commit
09e29aea96
@ -131,7 +131,7 @@ input, textarea {
|
||||
.fa-bars, .fa-cog {
|
||||
font-size: 200%;
|
||||
height: 100%;
|
||||
padding: 0.6%;
|
||||
padding: 0.65%;
|
||||
padding-right: 0.8%;
|
||||
|
||||
float: left;
|
||||
@ -166,7 +166,6 @@ input, textarea {
|
||||
}
|
||||
|
||||
#logout {
|
||||
width: initial;
|
||||
padding: 1%;
|
||||
|
||||
background-color: rgba(0,0,0,0.05);
|
||||
|
||||
@ -46,6 +46,7 @@ Session.set("modifying",null);
|
||||
Session.set("radioDiv",null);
|
||||
Session.set("radioOffset",null);
|
||||
Session.set("serverData",null);
|
||||
Session.set("noclass",null);
|
||||
|
||||
Template.registerHelper('divColor', (div) => {
|
||||
return themeColors[Cookie.get("theme")][div];
|
||||
@ -62,13 +63,14 @@ Template.registerHelper('overlayDim', (part) => {
|
||||
|
||||
Template.registerHelper('myClasses', () => {
|
||||
if (Meteor.user().profile.classes === undefined || Meteor.user().profile.classes.length === 0) {
|
||||
Session.set("noclass",true);
|
||||
return [];
|
||||
} else {
|
||||
var array = [];
|
||||
var courses = Meteor.user().profile.classes;
|
||||
for(var i = 0; i < courses.length; i++) {
|
||||
found = classes.findOne({_id:courses[i]});
|
||||
|
||||
found.subscribers = found.subscribers.length;
|
||||
if(found.admin === Meteor.userId()) found.box = " owned";
|
||||
array.push(found);
|
||||
|
||||
@ -80,6 +82,7 @@ Template.registerHelper('myClasses', () => {
|
||||
}
|
||||
array[i].thisClassWork = thisWork;
|
||||
}
|
||||
Session.set("noclass",false);
|
||||
return array;
|
||||
}
|
||||
});
|
||||
|
||||
@ -210,7 +210,7 @@
|
||||
animation: expand .7s ease 1;
|
||||
}
|
||||
|
||||
#profClassSearch .-autocomplete-container {
|
||||
.-autocomplete-container {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@ -278,6 +278,25 @@
|
||||
background-color: rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
#private {
|
||||
margin: 3% 35% 0 4%;
|
||||
padding: 1.5%;
|
||||
|
||||
background-color: rgba(0,0,0,0.2);
|
||||
|
||||
float: right;
|
||||
cursor: pointer;
|
||||
|
||||
-webkit-transition: background-color 0.4s ease;
|
||||
-moz-transition: background-color 0.4s ease;
|
||||
-ms-transition: background-color 0.4s ease;
|
||||
transition: background-color 0.4s ease;
|
||||
}
|
||||
|
||||
#private:hover {
|
||||
background-color: rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.owned {
|
||||
background-color: #27646D;
|
||||
|
||||
@ -328,7 +347,6 @@
|
||||
margin-right: 5% !important;
|
||||
margin-bottom: 0 !important;
|
||||
position: relative;
|
||||
|
||||
}
|
||||
|
||||
.formDiv {
|
||||
@ -346,9 +364,10 @@
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.-autocomplete-container {
|
||||
.formDiv .-autocomplete-container {
|
||||
margin: 0 0 0 0 !important;
|
||||
position: absolute;
|
||||
display: inherit !important;
|
||||
}
|
||||
|
||||
#creSubmit {
|
||||
|
||||
@ -59,12 +59,16 @@
|
||||
{{#each myClasses}}
|
||||
{{> classDisplay}}
|
||||
{{/each}}
|
||||
{{#if noclass}}
|
||||
<h3>No results found...</h3>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if profClassTab "addClass"}}
|
||||
<i class="fa fa-search" aria-hidden="true"></i>
|
||||
{{> inputAutocomplete id="profClassSearch" settings=classsettings placeholder="Search..."}}
|
||||
<h4 id="private">Join Private Class</h4>
|
||||
<div id="label" class="classBox">
|
||||
<span class="name classText">Class Name</span>
|
||||
<span class="teacher classText">Teacher</span>
|
||||
@ -76,12 +80,15 @@
|
||||
{{#each classes}}
|
||||
{{> classDisplay}}
|
||||
{{/each}}
|
||||
{{#if noclass}}
|
||||
<h3>No results found...</h3>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#each autocompleteClasses}}
|
||||
{{> classDisplay}}
|
||||
{{/each}}
|
||||
{{#if notfound}}
|
||||
<h3>No results found...</h3>
|
||||
<h3>No results found...</h3>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
@ -2,7 +2,6 @@ import {
|
||||
Template
|
||||
} from 'meteor/templating';
|
||||
|
||||
|
||||
Meteor.subscribe('schools');
|
||||
Meteor.subscribe('classes');
|
||||
Meteor.subscribe('work');
|
||||
@ -19,6 +18,8 @@ Session.set("confirmText", null);
|
||||
Session.set("selectedClass",null);
|
||||
Session.set("selectClassId",null);
|
||||
Session.set("code",null);
|
||||
Session.set("noclass",null);
|
||||
Session.set("notfound",null);
|
||||
|
||||
var themeColors = {
|
||||
"light": {
|
||||
@ -103,7 +104,6 @@ Template.profile.helpers({
|
||||
pic = Meteor.user().profile.avatar;
|
||||
} else {
|
||||
pic = "Avatars/" + (Math.floor(Math.random() * (11 - 1)) + 1).toString() + ".png";
|
||||
console.log(pic);
|
||||
currentprofile = Meteor.user().profile;
|
||||
currentprofile.avatar = pic;
|
||||
Meteor.call("editProfile", currentprofile);
|
||||
@ -139,7 +139,7 @@ Template.profile.helpers({
|
||||
}
|
||||
},
|
||||
classes() {
|
||||
return classes.find(
|
||||
var array = classes.find(
|
||||
{
|
||||
status: {$eq: true},
|
||||
privacy: {$eq: false},
|
||||
@ -148,6 +148,16 @@ Template.profile.helpers({
|
||||
{sort: {subscribers: -1 }},
|
||||
{limit: 20}
|
||||
).fetch();
|
||||
|
||||
for(var i = 0; i < array.length; i++) {
|
||||
array[i].subscribers = array[i].subscribers.length;
|
||||
}
|
||||
if(array.length === 0) {
|
||||
Session.set("noclass",true);
|
||||
} else {
|
||||
Session.set("noclass",false);
|
||||
}
|
||||
return array;
|
||||
},
|
||||
profClassHeight() {
|
||||
return 0.6 * window.innerHeight.toString() + "px";
|
||||
@ -178,6 +188,9 @@ Template.profile.helpers({
|
||||
notfound() {
|
||||
return Session.get("notfound");
|
||||
},
|
||||
noclass() {
|
||||
return Session.get("noclass");
|
||||
},
|
||||
confirmText() {
|
||||
return Session.get("confirmText");
|
||||
},
|
||||
@ -387,8 +400,8 @@ Template.profile.events({
|
||||
'click .fa-times-thin' () {
|
||||
Session.set("searching", false);
|
||||
},
|
||||
'keydown #profClassSearch' (event) {
|
||||
if (event.target.value === "") {
|
||||
'keyup #profClassSearch' (event) {
|
||||
if (event.target.value.length === 0) {
|
||||
Session.set("notsearching", true);
|
||||
} else {
|
||||
Session.set("notsearching", false);
|
||||
@ -409,7 +422,7 @@ Template.profile.events({
|
||||
name: item.childNodes[1].childNodes[0].nodeValue,
|
||||
teacher: item.childNodes[3].childNodes[0].nodeValue,
|
||||
hour: item.childNodes[5].childNodes[0].nodeValue,
|
||||
subscribers: item.childNodes[7].childNodes[0].nodeValue,
|
||||
subscribers: item.childNodes[7].childNodes[0].nodeValue.length/17,
|
||||
_id: item.getAttribute("classid")
|
||||
});
|
||||
Session.set("autocompleteDivs", divs);
|
||||
@ -475,16 +488,17 @@ Template.profile.events({
|
||||
input.placeholder = "1234@abc.xyz";
|
||||
input.className.replace(" formInvalid","");
|
||||
var value = input.value;
|
||||
var classid = document.getElementById("createdClasses").getAttribute("classid");
|
||||
input.value = "";
|
||||
if(checkUser(value)) {
|
||||
if(checkUser(value,classid)) {
|
||||
input.className += " formInvalid";
|
||||
input.placeholder = "Not a valid user";
|
||||
return;
|
||||
}
|
||||
var user = Meteor.users.findOne({"services.google.email":input.value});
|
||||
var user = Meteor.users.findOne({"services.google.email":value});
|
||||
Session.set("serverData", [
|
||||
user._id,
|
||||
document.getElementById("createdClasses").getAttribute("classid"),
|
||||
classid,
|
||||
event.target.parentNode.childNodes[1].childNodes[0].nodeValue.replace(":","").toLowerCase()
|
||||
]);
|
||||
sendData("trackUserInClass");
|
||||
@ -526,12 +540,19 @@ Template.profile.events({
|
||||
input.placeholder = "1234@abc.xyz";
|
||||
input.className.replace(" formInvalid","");
|
||||
var value = input.value;
|
||||
var classid = document.getElementById("createdClasses").getAttribute("classid");
|
||||
input.value = "";
|
||||
if(checkUser(value)) {
|
||||
if(checkUser(value,classid)) {
|
||||
input.className += " formInvalid";
|
||||
input.placeholder = "Not a valid user";
|
||||
return;
|
||||
}
|
||||
var user = Meteor.users.findOne({"services.google.email":value});
|
||||
Session.set("serverData", [user._id,classid]);
|
||||
Session.set("confirm","changeAdmin");
|
||||
Session.set("confirmText", "Are you really sure?");
|
||||
openDivFade(document.getElementsByClassName("overlay")[0])
|
||||
document.getElementById("createdClasses").style.marginRight = "-40%";
|
||||
}
|
||||
});
|
||||
|
||||
@ -632,11 +653,12 @@ function getCreateFormData() {
|
||||
};
|
||||
}
|
||||
|
||||
function checkUser(email) {
|
||||
function checkUser(email,classid) {
|
||||
var user = Meteor.users.findOne({"services.google.email":email});
|
||||
if(user === undefined) {
|
||||
return true;
|
||||
} else {
|
||||
if(classes.findOne({_id:classid}).subscribers)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user