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

Ht 38 select task #51

Merged
merged 17 commits into from
Mar 15, 2017
Merged

Ht 38 select task #51

merged 17 commits into from
Mar 15, 2017

Conversation

feenster
Copy link
Contributor

Looking for a first review of the code please

@feenster feenster requested a review from LindaAlblas March 13, 2017 12:50
Copy link
Contributor

@LindaAlblas LindaAlblas left a comment

Choose a reason for hiding this comment

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

Some initial comments

}

vm.selectRandomTask = function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

add function comment

var layers = vm.map.getLayers();
for (var i = 0; i < layers.getLength(); i++) {
if (layers.item(i).get('name') === 'tasks') {
var feature = layers.item(i).getSource().getFeatures().filter(function (feature) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of iterating over the layers, you could store the vector layer as a controller variable and reference it directly.

select.getFeatures().clear();
select.getFeatures().push(feature);
onTaskSelection(feature);
var vPadding = vm.map.getSize()[1] * 0.3;
Copy link
Contributor

Choose a reason for hiding this comment

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

Explain with a comment what this magic number is exactly

@feenster
Copy link
Contributor Author

@LindaAlblas OK, looking to merge now, if you could have a good look. Thanks.

@feenster
Copy link
Contributor Author

@LindaAlblas for the comment on the merge can we please discuss when you get to that stage. Thanks.

@LindaAlblas
Copy link
Contributor

@feenster , working on it!

Copy link
Contributor

@LindaAlblas LindaAlblas left a comment

Choose a reason for hiding this comment

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

A few more comments. Mainly readability + docs.

vm.mappingStep = 'view';
}, function () {
// task not returned successfully
// TODO - may want to handle error
Copy link
Contributor

Choose a reason for hiding this comment

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

The error is handled so we can remove the TODO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -86,5 +144,31 @@
});
source.addFeature(aoiFeatures);
}

/**
* Gets a task from the server and uses sets up the task returned as the currently selected task
Copy link
Contributor

Choose a reason for hiding this comment

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

typo in description

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

<h3>*Mapping*</h3>
<button class="button button--secondary">Start Mapping</button>
<div class="content">
<div class="button-group button-group--horizontal" role="group" aria-label="...">
Copy link
Contributor

Choose a reason for hiding this comment

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

it is good practice to put a description in the aria-label

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


// read tasks JSON into features
console.log(tasks);
Copy link
Contributor

Choose a reason for hiding this comment

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

remove console.log

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

*/
function initialiseProject(id){
vm.selectRandomTask = function () {
var feature = taskService.getRandomMappableTaskFeature(vm.taskVectorLayer.getSource().getFeatures());
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks a lot neater now 👍

ng-hide="projectCtrl.selectedTask.taskLocked"> {{ projectCtrl.selectedTask.taskStatus }} </span>
</h3>


Copy link
Contributor

Choose a reason for hiding this comment

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

tidy up whitespaces

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

*/
function getRandomMappableTaskFeature(features) {
//first check that we have a non empty array of ol.Feature objects
if (features && (Object.prototype.toString.call(features) === '[object Array]') && features.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

could you use features instanceof Array instead of Object.prototype? Or would if (features && features.length > 0) even be enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

*/
function getTasksByStatus(features, taskLocked, taskStatus) {
candidates = [];
if (features && (Object.prototype.toString.call(features) === '[object Array]') && features.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same as comment above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

// safe to use the function
var isLocked = item.get('taskLocked');
var status = item.get('taskStatus');
if (item.get('taskLocked') == taskLocked && item.get('taskStatus') === taskStatus) return item;
Copy link
Contributor

Choose a reason for hiding this comment

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

You have declared the variables isLocked and status so you can use them. Makes it easier to read too :)

if (isLocked == taskLocked && status == taskStatus){
return item;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,254 @@
'use strict';

describe('task.service', function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@feenster
Copy link
Contributor Author

@LindaAlblas that's the requested changes done

@LindaAlblas LindaAlblas merged commit 03d93fc into develop Mar 15, 2017
@LindaAlblas LindaAlblas deleted the ht-38-select-task branch March 15, 2017 14:46
varun2948 added a commit to varun2948/tasking-manager that referenced this pull request Jan 30, 2024
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.

2 participants