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

Fix front-end Helpers.ifHasPermissions #1345

Merged
merged 9 commits into from
Apr 4, 2018
Merged

Fix front-end Helpers.ifHasPermissions #1345

merged 9 commits into from
Apr 4, 2018

Conversation

taylortom
Copy link
Member

@taylortom taylortom commented Aug 22, 2016

Fixes #1344

@taylortom taylortom added this to the 0.3.0 User Management milestone Sep 5, 2016
@taylortom taylortom removed this from the 0.3.0 User Management milestone Sep 12, 2016
Copy link
Contributor

@tomgreenfield tomgreenfield left a comment

Choose a reason for hiding this comment

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

Looks like you're already started to revamp the entire file with formatting fixes, good man. I did a quick lint to pick up the rest. All stylistic updates of course.

ifUserIsMe: function(userId, block) {
if (userId === Origin.sessionModel.get('id')) {
return block.fn(this);
} else {
return block.inverse(this);
}
},

selected: function(option, value){
if (option === value) {
return ' selected';
} else {
return ''
Copy link
Contributor

@tomgreenfield tomgreenfield Sep 16, 2016

Choose a reason for hiding this comment

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

Missing semi-colon.

@@ -221,8 +237,7 @@ define(function(require){
},
Copy link
Contributor

@tomgreenfield tomgreenfield Sep 16, 2016

Choose a reason for hiding this comment

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

Line 232, update to strict equality:

url.indexOf('course/assets') === 0

@@ -253,47 +268,45 @@ define(function(require){
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Line 262 missing semi-colon.

counterFromOne: function(n, block) {
var sum = '';
for (var i = 1; i <= n; ++i)
sum += block.fn(i);
return sum;
},

t: function(str, options) {
for (var placeholder in options.hash) {
options[placeholder] = options.hash[placeholder];
}
return (window.polyglot != undefined ? window.polyglot.t(str, options) : str);
Copy link
Contributor

Choose a reason for hiding this comment

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

Update to strict equality:

window.polyglot !== undefined

stripHtml: function(html) {
return new Handlebars.SafeString(html);
},

bytesToSize: function(bytes) {
if (bytes == 0) return '0 B';
Copy link
Contributor

Choose a reason for hiding this comment

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

Update to strict equality:

bytes === 0

@canstudios-davidl
Copy link

Hi, any update on what's happening with this PR? I've just encountered this bug but see there's already a fix for it... PR looks a bit stale though.
Thanks

@taylortom
Copy link
Member Author

@canstudios-davidl I'll pick this up for the next release

@taylortom taylortom self-assigned this Jul 3, 2017
@taylortom taylortom added this to the 0.4.0 Refactor milestone Jul 3, 2017
@canstudios-davidl
Copy link

Thanks @taylortom happy to help if needed

@taylortom taylortom removed this from the 0.4.0 Refactor milestone Jul 25, 2017
@taylortom taylortom added this to the 0.5.0 Import/Export milestone Feb 5, 2018
@canstudios-louisem canstudios-louisem changed the base branch from master to develop February 19, 2018 10:31
@canstudios-louisem
Copy link
Contributor

Happy to approve once the conflicts are resolved.

* develop: (409 commits)
  ignore .vscode and package-lock.json
  supress npm warnings
  article view now generated after article model saved
  Fixes #1772
  Amend check to allow undefined data
  Switch to local log func
  Stop throwing error if repo update check failed
  Fix version check
  Add override for removal of list items
  Handle response errors better
  amend title for clarity following code review
  better help text, more consistent use of '?' in titles
  remove some ARIA labels that were not used add the core properties _isVisible and _isHidden add missing 'instruction' property to article & block improve usability through better titles/help text
  Master changes (#1741)
  Fix bug with recursive function call
  Remove testing header
  Update CHANGELOG for release 0.4.0 (#1739)
  Enchancements to install/update (#1726)
  Amend contentModel._children to allow for arrays
  fixes 1474
  ...

# Conflicts:
#	frontend/src/core/helpers.js
* develop: (80 commits)
  update
  Check if user is course owner
  Require modules before plugins
  Change to ensureDirSync
  refactor to set scrollTop after all animations are completed
  hook into transition end event instead of post render
  Fixes #1906
  Allow MongoDB authentication in install script
  Fix modules define
  Fix globalData
  Make sure we load the plugin
  Fix issue with merge
  Save isVisible and isHidden on blocks and components
  Fix context menu for page
  Move plugin folder to modules
  Refactor for readability
  Update comments
  Fix plugin code broken in refactor
  Persist sort prefs indefinitely
  Remove config-sample.json
  ...

# Conflicts:
#	frontend/src/core/helpers.js
@taylortom taylortom merged commit b92c928 into develop Apr 4, 2018
@taylortom taylortom deleted the issue/1344 branch April 4, 2018 13:31
Copy link
Contributor

@tomgreenfield tomgreenfield left a comment

Choose a reason for hiding this comment

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

Sorry I was too late with my review – will probably need a new PR to fix the pickCSV() function.

pickCSV: function (list, key, separator) {
var vals = [];
separator = (separator && separator.length) ? separator : ',';
if (list && list.length) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the logic hasn't been reversed here when returning early.

Anyhow, suggest refactoring to return right at the start of the function. Something like:

pickCSV: function(list, key, separator) {
  if (!list || !list.length) {
    return '';
  }
  var vals = [];
  if (!separator || !separator.length) {
    separator = ',';
  }
  for (var i = 0, l = list.length; i < l; i++) {
    var val = list[i];
    var nestedVal = key && val[key];
    vals.push(nestedVal || val);
  }
  return vals.join(separator);
}

},

ifImageIsCourseAsset: function(url, block) {
var isCourseAsset = url.length !== 0 && url.indexOf('course/assets') == 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use triple equals: url.indexOf('course/assets') === 0

}
},
bytesToSize: function(bytes) {
if (bytes == 0) return '0 B';
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use triple equals: bytes === 0.

@taylortom taylortom mentioned this pull request Apr 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants