Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

separate section for hidden quesions added #107

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion client/views/list/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,19 @@ <h2>Moderator Interface</h2>
{{> question_div}}
{{/if}}
{{/each}}
</div>
</div>
{{#if hiddenQuestionsPresent}}
<hr>
<div class="container" id="quest-container">
{{#each question}}
{{#if invisible}}
{{#if adminMod}}
{{> question_div}}
{{/if}}
{{/if}}
{{/each}}
</div>
{{/if}}
</div>
{{> footer}}
</div>
Expand Down
40 changes: 37 additions & 3 deletions client/views/list/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,15 @@ Template.list.helpers({
if (this.state !== 'disabled') return true;

if (isPresenting === true) return false;

},
invisible() {
if (this.state == 'disabled') return true;
return false;
},
adminMod() {
let tableAdmin = false;
let tableMod = false;
let instance = Instances.findOne({ _id: this.instanceid });
const instance = Instances.findOne({ _id: this.instanceid });

if (Meteor.user()) {
const userEmail = Meteor.user().emails[0].address;
Expand All @@ -283,9 +288,38 @@ Template.list.helpers({
tableMod = true;
}
}

return tableAdmin || tableMod;
},
hiddenQuestionsPresent() {
let questions;
if (Session.get('search') === 'all') {
questions = Template.instance().visibleQuestions.find({
instanceid: Template.instance().data._id,
}).fetch();
} else {
const re = new RegExp(Session.get('search'), 'i');
questions = Template.instance().visibleQuestions.find({
instanceid: Template.instance().data._id,
$or: [{
text: {
$regex: re,
},
}, {
poster: {
$regex: re,
},
}],
}).fetch();
}
let noOfHiddenQues = 0;
questions.forEach(function(question) {
if (question.state === 'disabled')
noOfHiddenQues += 1;
});
if(noOfHiddenQues > 0)
return true;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could return true from inside the loop when you get the first hidden question.
That would make it more efficient and faster as in that case comparatively lesser number of iterations would be required.
This could affect the time complexity and efficiency of code drastically when there are larger number of hidden questions.

return false;
},
hasSeconds() {
return Template.instance().seconds.get() > 0 && !Template.instance().state.get('typing');
},
Expand Down
7 changes: 7 additions & 0 deletions client/views/list/list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ $screen-sm: 768px;
font-weight: 700;
}

hr{
border: 0px;
height: 0.3px!important;
color: grey;
margin-bottom: 2%;
background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}

.description {
display: block;
Expand Down