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

Changes made to the calcontroller.js file for sharing multiple tokens #765

Closed
wants to merge 7 commits into from

Conversation

arunikayadav42
Copy link

I was working on the issue to make more than one calendars visible on the same page.Thus different tokens separated by "." were split using "." as the delimiter and each token was accessed individually.

@opticod
Copy link

opticod commented Mar 11, 2018

@arunikayadav42 TravisCI is failing due to JSHint which is a tool that helps to detect errors and potential problems in your JavaScript code. Try fixing this, and repush again, to ran travis again. You can get more info by clicking each build jobs in travis site.

@@ -140,15 +140,20 @@ app.controller('CalController', ['$scope', 'Calendar', 'CalendarService', 'VEven
$scope.$apply();
});
} else {
$scope.calendarsPromise = CalendarService.getPublicCalendar(constants.publicSharingToken).then(function(calendar) {
var splitted = constants.publicSharingToken.split(".")
Copy link
Member

Choose a reason for hiding this comment

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

Please add a semicolon here :)

$scope.calendarsPromise = CalendarService.getPublicCalendar(constants.publicSharingToken).then(function(calendar) {
var splitted = constants.publicSharingToken.split(".")
var i;
for(i = 0; i < splitted.length; i++ )
Copy link
Member

Choose a reason for hiding this comment

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

You could also use constants.publicSharingToken.split(".").forEach(token => {...} here :)

var i;
for(i = 0; i < splitted.length; i++ )
{
$scope.calendarsPromise = CalendarService.getPublicCalendar(splitted[i]).then(function(calendar) {
$scope.calendars = [calendar];
is.loading = false;
// TODO - scope.apply should not be necessary here
$scope.$apply();
Copy link
Member

Choose a reason for hiding this comment

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

Please only call is.loading = false and $scope.$apply(); once all calendars are done loading and not for each individually.

@arunikayadav42
Copy link
Author

@georgehrke I have made the necessary changes, please review my request :)

is.loading = false;
// TODO - scope.apply should not be necessary here
$scope.$apply();
}).catch((reason) => {
}).catch((reason) => {
angular.element('#header-right').css('display', 'none');
Copy link
Member

Choose a reason for hiding this comment

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

Seems to be indent issues here. Does your editor understands .editorconfig files (maybe with a plugin) ?

Copy link
Author

Choose a reason for hiding this comment

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

@tcitworld I am using sublime text to edit the code, can you please explain why my pull request can't be merged :)

Copy link
Member

Choose a reason for hiding this comment

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

Install this package : https://packagecontrol.io/packages/EditorConfig

There's a few indenting issues I see (when opening a bracket, add a new line indented).

Copy link
Author

Choose a reason for hiding this comment

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

I have installed the package and restarted the sublime text but still cannot see any changes made in the indentation of the code.

Copy link
Member

Choose a reason for hiding this comment

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

I didn't use Sublime Text for a while, doesn't it shows some errors somehow ?

Don't bother too much for this, I'll fix these kind of typos afterwards.

angular.element('#header-right').css('display', 'none');
angular.element('#emptycontent-container').css('display', 'block');
});
});
Copy link
Member

Choose a reason for hiding this comment

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

Remove spaces here

@@ -140,15 +140,18 @@ app.controller('CalController', ['$scope', 'Calendar', 'CalendarService', 'VEven
$scope.$apply();
});
} else {
$scope.calendarsPromise = CalendarService.getPublicCalendar(constants.publicSharingToken).then(function(calendar) {
constants.publicSharingToken.split(".").forEach(token=>
Copy link
Member

Choose a reason for hiding this comment

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

Add spaces before and after token, and I think it should be inside some parenthesis.

}).catch((reason) => {
angular.element('#header-right').css('display', 'none');
angular.element('#emptycontent-container').css('display', 'block');
});
});
Copy link
Member

Choose a reason for hiding this comment

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

Remove spaces added at the end of the line.

Copy link
Author

Choose a reason for hiding this comment

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

Is it alright now or do I further look into the indentation ,please tell :)

Copy link

Choose a reason for hiding this comment

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

@arunikayadav42 No, its still there. Remove spaces added at the end of the line.

constants.publicSharingToken.split(".").forEach(token=>
{
$scope.calendarsPromise = CalendarService.getPublicCalendar(token).then(function(calendar) {
$scope.calendars = [calendar];
Copy link
Member

@tcitworld tcitworld Mar 13, 2018

Choose a reason for hiding this comment

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

If I'm not wrong, this will overwrite $scope.calendars with an array of the current calendar only. You need to push it instead, like $scope.calendars.push(calendar);.

@arunikayadav42
Copy link
Author

Can I please know if something remains that is preventing from getting this PR merged :)

@tcitworld
Copy link
Member

See #765 (comment)

@arunikayadav42
Copy link
Author

Do you mean the scope.calendars statement needs to be rectified?

@arunikayadav42
Copy link
Author

@tcitworld I have already changed the indentation, can you please tell me what further remains to change?

@opticod
Copy link

opticod commented Mar 17, 2018

@arunikayadav42 No, its still there. Remove spaces added at the end of the line.

$scope.calendars = [calendar];
constants.publicSharingToken.split(".").forEach( (token) => {
$scope.calendarsPromise = CalendarService.getPublicCalendar(token).then(function(calendar) {
$scope.calendars = [calendar];
Copy link
Member

Choose a reason for hiding this comment

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

This is still wrong. You are always overwriting $scope.calendars with a new array with one item here.
Instead you need to initialize an empty array first and push each calendar into the array individually.

@arunikayadav42
Copy link
Author

@georgehrke or @tcitworld please review :)

constants.publicSharingToken.split(".").forEach( (token) => {
$scope.calendarsPromise = CalendarService.getPublicCalendar(token).then(function(calendar) {
$scope.calendars.push(calendar);
});
Copy link
Member

Choose a reason for hiding this comment

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

I'm sorry, but the indentation is still wrong. This should be indented by one tab.

constants.publicSharingToken.split(".").forEach( (token) => {
$scope.calendarsPromise = CalendarService.getPublicCalendar(token).then(function(calendar) {
$scope.calendars.push(calendar);
});
is.loading = false;
// TODO - scope.apply should not be necessary here
$scope.$apply();
Copy link
Member

Choose a reason for hiding this comment

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

These two lines are still called for each calendar. Please only call them once all calendars loaded.

To make sure they are called after all are done, you need to create an array with all CalendarService.getPublicCalendar(token) promises and do a Promise.all() on the array.

For more information about Promise functions see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all

Copy link
Member

Choose a reason for hiding this comment

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

Furthermore the catch is currently called on the forEach function. It has to be called on the Promise instead.

Copy link
Author

Choose a reason for hiding this comment

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

I will look into the same :)

@haug-den-lucas
Copy link

haug-den-lucas commented Jul 12, 2018

There's also another problem:
The "Embed" icon on the bottom will only show the embed code for one of the calendars.
This is fixed in: #865

@georgehrke
Copy link
Member

Stale, closing in favor of #870, which is implementing the same

@georgehrke georgehrke closed this Aug 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants