Started adding async calls for upgrading to Meteor 3.0. Numerous other fixes.
This commit is contained in:
@@ -21,7 +21,7 @@ Template.Sales.onCreated(function() {
|
||||
Session.set(PREFIX + "sortOption", "date");
|
||||
Session.set(PREFIX + "showOnlyComments", false);
|
||||
|
||||
Tracker.autorun(function() {
|
||||
Tracker.autorun(async function() {
|
||||
let sortOption = Session.get(PREFIX + "sortOption");
|
||||
let sort = sortOption == 'createdAt' ? {createdAt: -1} : {date: -1, createdAt: -1};
|
||||
let showOnlyComments = Session.get(PREFIX + "showOnlyComments");
|
||||
@@ -34,7 +34,7 @@ Template.Sales.onCreated(function() {
|
||||
|
||||
//if(Template.Sales.salesSubscription) Template.Sales.salesSubscription.stop();
|
||||
Template.Sales.salesSubscription = Meteor.subscribe("sales", query, sort, QUERY_LIMIT, Session.get(PREFIX + 'skipCount'));
|
||||
Session.set(PREFIX + 'saleCount', Meteor.call('getSalesCount', Session.get(PREFIX + 'searchQuery')));
|
||||
Session.set(PREFIX + 'saleCount', await Meteor.callAsync('getSalesCount', Session.get(PREFIX + 'searchQuery')));
|
||||
});
|
||||
});
|
||||
Template.Sales.onRendered(function() {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import './SalesSheetEditor.html';
|
||||
import swal from 'sweetalert2';
|
||||
import dragula from 'dragula';
|
||||
import { ReactiveDict } from 'meteor/reactive-dict'
|
||||
|
||||
let PREFIX = "SalesSheetEditor.";
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
import './SalesSheetForm.html';
|
||||
import swal from 'sweetalert2';
|
||||
import { ReactiveDict } from 'meteor/reactive-dict'
|
||||
|
||||
let PREFIX = "SalesSheetForm.";
|
||||
|
||||
|
||||
@@ -60,7 +60,8 @@
|
||||
<div class="rolesContainer editorDiv"><label>Roles:</label>
|
||||
<div class="roles center" style="font-size: 1.2em">
|
||||
{{#each allRoles}}
|
||||
<span class="role {{getRoleState this}} noselect">{{name}}</span>
|
||||
<!-- Roles no longer have a name, they now put the name as the _id in Mongo -->
|
||||
<span class="role {{getRoleState this}} noselect">{{_id}}</span>
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -9,6 +9,7 @@ let PREFIX = "UserManagement";
|
||||
|
||||
Tracker.autorun(function() {
|
||||
Meteor.subscribe("users", Session.get(PREFIX + 'searchQuery'));
|
||||
Meteor.subscribe("roleAssignments");
|
||||
Meteor.subscribe("roles");
|
||||
});
|
||||
|
||||
@@ -132,6 +133,15 @@ Template.User.helpers({
|
||||
let editedUser = Session.get(PREFIX + "editedUser");
|
||||
|
||||
return editedUser == this._id;
|
||||
},
|
||||
roles: function() {
|
||||
let roles = Meteor.roleAssignment.find({"user._id": this._id}, {"sort": [["role._id", "asc"]]}).fetch();
|
||||
let result = []
|
||||
|
||||
for(let next of roles)
|
||||
result.push(next.role._id)
|
||||
|
||||
return result
|
||||
}
|
||||
});
|
||||
|
||||
@@ -145,7 +155,15 @@ Template.UserEditor.helpers({
|
||||
getRoleState: function(role) {
|
||||
let user = Template.parentData(1);
|
||||
|
||||
return !user.isNew && user.roles.includes(role.name) ? "selected" : "";
|
||||
//Debug code...
|
||||
// console.log("GetRoleState")
|
||||
// console.log(role._id)
|
||||
// console.log(user._id)
|
||||
// console.log(Meteor.roleAssignment.find({"user._id": user._id, "role._id": role._id}).count())
|
||||
//console.log("Role: " + role._id + " === " + Roles.userIsInRole(user._id, [role._id]))
|
||||
|
||||
// Note: Meteor.roleAssignment.countDocuments({...}) returns a Promise and not a count. Cannot use that here.
|
||||
return Roles.userIsInRole(user._id, [role._id]) ? "selected" : ""
|
||||
}
|
||||
});
|
||||
Template.UserEditor.events({
|
||||
@@ -166,10 +184,10 @@ Template.UserEditor.events({
|
||||
roles.push($(roleSpans[i]).text());
|
||||
}
|
||||
|
||||
user.roles = roles;
|
||||
//user.roles = roles;
|
||||
|
||||
if(Session.get(PREFIX + 'displayNewUser')) {
|
||||
Meteor.call('insertUser', user, function(error, result) {
|
||||
Meteor.call('insertUser', user, roles, function(error, result) {
|
||||
if(error) {
|
||||
sAlert.error(error);
|
||||
}
|
||||
@@ -182,7 +200,7 @@ Template.UserEditor.events({
|
||||
}
|
||||
else {
|
||||
user._id = this._id;
|
||||
Meteor.call("updateUser", user, function(error, result) {
|
||||
Meteor.call("updateUser", user, roles, function(error, result) {
|
||||
if(error) sAlert.error(error);
|
||||
else {
|
||||
sAlert.success("User updated.");
|
||||
|
||||
Reference in New Issue
Block a user