Skip to content

Commit

Permalink
Merge pull request #895 from eciis/fix-cards-that-use-calculateheight…
Browse files Browse the repository at this point in the history
…-function

Removing calculateHeight from the system
  • Loading branch information
mayzabeel authored Mar 14, 2018
2 parents 566979d + 9b8f61d commit 1ea5f04
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 64 deletions.
4 changes: 0 additions & 4 deletions frontend/institution/managementMembersController.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,6 @@
return isValid;
};

manageMemberCtrl.calculateHeight = function calculateHeight(list, itemHeight=4.5) {
return Utils.calculateHeight(list, itemHeight);
};

manageMemberCtrl.resendInvite = function resendInvite(inviteKey, event) {
var confirm = $mdDialog.confirm({ onComplete: designOptions });
confirm
Expand Down
4 changes: 0 additions & 4 deletions frontend/invites/inviteInstitutionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
inviteInstCtrl[flagName] = !inviteInstCtrl[flagName];
};

inviteInstCtrl.calculateHeight = function calculateHeight(list, itemHeight) {
return Utils.calculateHeight(list, itemHeight);
};

inviteInstCtrl.cancelInvite = function cancelInvite() {
inviteInstCtrl.invite = {};
};
Expand Down
6 changes: 3 additions & 3 deletions frontend/invites/invite_institution.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h1>
</div>
</md-toolbar>
<md-card-content ng-show="inviteInstCtrl.showInvites"
ng-style="inviteInstCtrl.calculateHeight(inviteInstCtrl.sent_invitations)" ng-scrollbars>
style="overflow: auto; max-height: 235px;" class="custom-scrollbar">
<md-list class="md-dense" flex>
<md-list-item class="md-3-line" ng-click="null" ng-repeat="invite in inviteInstCtrl.sent_invitations">
<md-icon class="md-avatar-icon"
Expand Down Expand Up @@ -86,7 +86,7 @@ <h1>
</div>
</md-toolbar>
<md-card-content ng-show="inviteInstCtrl.showRequests"
ng-style="inviteInstCtrl.calculateHeight(inviteInstCtrl.sent_requests)" ng-scrollbars>
style="overflow: auto; max-height: 240px;" class="custom-scrollbar">
<div flex >
<md-list class="md-dense" flex>
<md-list-item class="md-3-line" ng-repeat="request in inviteInstCtrl.sent_requests"
Expand Down Expand Up @@ -122,7 +122,7 @@ <h1>
</div>
</md-toolbar>
<md-card-content ng-show="inviteInstCtrl.showSentInvitations"
ng-style="inviteInstCtrl.calculateHeight(inviteInstCtrl.accepted_invitations)" ng-scrollbars>
style="overflow: auto; max-height: 235px;" class="custom-scrollbar">
<md-list class="md-dense" flex>
<md-list-item class="md-3-line" ng-repeat="invite in inviteInstCtrl.accepted_invitations">
<md-icon class="md-avatar-icon"
Expand Down
23 changes: 0 additions & 23 deletions frontend/test/specs/UtilsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,6 @@
.toEqual("Access: <a href='http://www.google.com' target='_blank'>http://www.google.com</a>");
});
});

describe('calculateHeight()', function() {
it('should set the height to 20em', function() {
var requests = ['req01', 'req02', 'req03', 'req05', 'req06'];
var calculatedHeigh = Utils.calculateHeight(requests);
var expectedHeight = {height: '20em'};
expect(calculatedHeigh).toEqual(expectedHeight);
});

it('should set height to less than 20em', function() {
var requests = ['req01', 'req02', 'req03'];
var calculatedHeigh = Utils.calculateHeight(requests);
var expectedHeight = {height: '15em'};
expect(calculatedHeigh).toEqual(expectedHeight);
});

it('should set height to 30em', function() {
var requests = ['req01', 'req02', 'req03', 'req05', 'req06'];
var calculatedHeigh = Utils.calculateHeight(requests, 10, 3);
var expectedHeight = {height: '30em'};
expect(calculatedHeigh).toEqual(expectedHeight);
});
});
}));


15 changes: 0 additions & 15 deletions frontend/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,6 @@ var Utils = {
generateLink : function generateLink(url){
return window.location.host + url;
},

/**
* Create an object with a calculated property height, to be used with
* the directive ng-style on a html element that has a list of itens in it.
* @param {array} list=[] A list of itens.
* @param {number} itemHeight=5 The css estimated height of one item.
* @param {number} maxItensNumber=4 The max number of itens to be shown in the element per scroll.
* @returns {object} The object with the property height.
*/
calculateHeight : function calculateHeight(list=[], itemHeight=5, maxItensNumber=4) {
var maxHeight = itemHeight * maxItensNumber + 'em';
var actualHeight = list.length * itemHeight + 'em';
var calculedHeight = list.length < maxItensNumber ? actualHeight : maxHeight;
return {height: calculedHeight};
},

setScrollListener: function setScrollListener(content, callback) {
var alreadyRequested = false;
Expand Down
15 changes: 0 additions & 15 deletions support/auth/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,6 @@ var Utils = {
return string && string.length > limit ?
string.substring(0, limit+1) + "..." : string;
},

/**
* Create an object with a calculated property height, to be used with
* the directive ng-style on a html element that has a list of itens in it.
* @param {array} list=[] A list of itens.
* @param {number} itemHeight=5 The css estimated height of one item.
* @param {number} maxItensNumber=4 The max number of itens to be shown in the element per scroll.
* @returns {object} The object with the property height.
*/
calculateHeight : function calculateHeight(list=[], itemHeight=5, maxItensNumber=4) {
var maxHeight = itemHeight * maxItensNumber + 'em';
var actualHeight = list.length * itemHeight + 'em';
var calculedHeight = list.length < maxItensNumber ? actualHeight : maxHeight;
return {height: calculedHeight};
},

setScrollListener: function setScrollListener(content, callback) {
var alreadyRequested = false;
Expand Down

0 comments on commit 1ea5f04

Please sign in to comment.