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

Add an "insert step" button on each step UI #466

Closed
jywarren opened this issue Nov 11, 2018 · 21 comments
Closed

Add an "insert step" button on each step UI #466

jywarren opened this issue Nov 11, 2018 · 21 comments

Comments

@jywarren
Copy link
Member

This code shows the excellent "insert step" method in use:

test('insertSteps("image",position,"module",options) inserts a step', function(t) {
sequencer.insertSteps('test', 1, 'channel', {});
t.equal(sequencer.images.test.steps.length, 3, "Length of Steps increased");
t.equal(sequencer.images.test.steps[1].options.name, "channel", "Correct Step Inserted");
t.end();
});

We should add a new button (next to the trash button) which lets you insert a new module:

sketch-1541958834514 png

See this for how the add step UI works, that could be adapted here:

The available modules are added to the select here:

// Add modules to the addStep dropdown
for (var m in modulesInfo) {
addStepSelect.append(
'<option value="' + m + '">' + modulesInfo[m].name + "</option>"
);
}

Here is how the "add step" button is triggered:

$("#addStep #add-step-btn").on("click", ui.addStepUi);

Here is the function that's run when the button is pressed; this could be adapted to accept a 'step' parameter too, so the insertion could happen at a different place in the sequence:

function addStepUi() {
if ($(addStepSel + " select").val() == "none") return;
var newStepName = $(addStepSel + " select").val();
/*
* after adding the step we run the sequencer from defined step
* and since loadImage is not a part of the drawarray the step lies at current
* length - 2 of the drawarray
*/
var sequenceLength = 1;
if (sequencer.sequences[newStepName]) {
sequenceLength = sequencer.sequences[newStepName].length;
} else if (sequencer.modules[newStepName][1]["length"]) {
sequenceLength = sequencer.modules[newStepName][1]["length"];
}
_sequencer
.addSteps(newStepName, options)
.run({ index: _sequencer.images.image1.steps.length - sequenceLength - 1 });
// add to URL hash too
setUrlHashParameter("steps", _sequencer.toString());
}

@holykol perhaps you'd be interested in this one? Or someone else? We'd love some help!

@gitmate
Copy link

gitmate bot commented Nov 11, 2018

GitMate.io thinks the contributor most likely able to help you is @tech4GT.

Possibly related issues are #348 (Improve Images step Ui), #205 (add "drag to crop" UI feature to Crop module), #433 (display add step menu with common modules as "quick" buttons), #432 (display add step menu with common modules as "quick" buttons), and #303 (Disable/dim the Add step button until a module is selected).

1 similar comment
@gitmate
Copy link

gitmate bot commented Nov 11, 2018

GitMate.io thinks the contributor most likely able to help you is @tech4GT.

Possibly related issues are #348 (Improve Images step Ui), #205 (add "drag to crop" UI feature to Crop module), #433 (display add step menu with common modules as "quick" buttons), #432 (display add step menu with common modules as "quick" buttons), and #303 (Disable/dim the Add step button until a module is selected).

@Divy123
Copy link
Member

Divy123 commented Nov 13, 2018

@jywarren can I work on this?
Looks interesting to me.

@jywarren
Copy link
Member Author

jywarren commented Nov 13, 2018 via email

@jonxuxu
Copy link
Member

jonxuxu commented Nov 26, 2018

Hey I'm interested in this task! Is anyone working on it? Just to clarify, will the add-step button display a drop-down and do the same thing as the "add-step" button on the bottom of the page?
image

@jywarren
Copy link
Member Author

jywarren commented Nov 26, 2018 via email

@jonxuxu
Copy link
Member

jonxuxu commented Nov 26, 2018

Oh cool, thanks for clarifying. And I presume it hides itself after a new step is created? I'd love to work on this task but I'm not sure if someone else is working on it...

@jywarren
Copy link
Member Author

jywarren commented Nov 27, 2018 via email

@Divy123
Copy link
Member

Divy123 commented Nov 27, 2018

I am working on it actually.
Sorry for being late.I am having my semester exams right now.
So will continue after 30th Nov.

@jywarren
Copy link
Member Author

jywarren commented Nov 27, 2018 via email

@jonxuxu
Copy link
Member

jonxuxu commented Nov 28, 2018

Ah no worries, good luck on your exams!

@jywarren
Copy link
Member Author

jywarren commented Dec 12, 2018 via email

@Divy123
Copy link
Member

Divy123 commented Dec 14, 2018

Thanks @jywarren .One more thing while the majority of the work is done, that please look into the screenshot below:
screenshot from 2018-12-14 21-03-21.
Getting a basic understanding I have added appropriate index in the run function but still the step is being added at the last. Can you please guide me on this?

@tech4GT
Copy link
Member

tech4GT commented Dec 14, 2018

@Divy123 I think the problem here is not with run but with addSteps method, I think we need to use the insertSteps method to put the steps in the right order.

@tech4GT
Copy link
Member

tech4GT commented Dec 14, 2018

I think the function needs the image too, do check out the example given by @jywarren above and try it in that format, if that doesn't work I'll be more than happy to look at your code.
PS It's kind of late here so I may get to it tom. 😄

@Divy123
Copy link
Member

Divy123 commented Dec 14, 2018

Thanks @tech4GT . Your advice is of great help.

@Divy123
Copy link
Member

Divy123 commented Dec 14, 2018

@tech4GT I tried passing ( _sequencer.images,id+1,stepName) as arguments to insertStep but then I am getting errors.
Probably the errors are due to me passing wrong arguments. Can you please help me understand the role of image in the set of parameters?
Attached is the error I am getting:
screenshot from 2018-12-14 23-59-56
_sequencer .insertSteps(_sequencer.images,id+1,newStepName) .run( {index: _sequencer.images.image1.steps.length - sequenceLength-1 } );is my code for insertStep.

@Divy123
Copy link
Member

Divy123 commented Dec 15, 2018

This particular problem is resolved as stated above!

@Divy123
Copy link
Member

Divy123 commented Dec 15, 2018

@tech4GT I have almost don the work. Just one thing is there I am not able to figure out.
The inserted step is added at the correct position in steps array, the url is getting updated correctly but in the UI the inserted step is always being added at the last.Though on a page refresh all the steps including the newly inserted one comes at its correct position. Can you please help me with that?

@tech4GT
Copy link
Member

tech4GT commented Dec 15, 2018

oh, try looking into the run function, I think the steps are not being re-run properly.

@tech4GT
Copy link
Member

tech4GT commented Dec 15, 2018

Try running it from 0, if that works then you can figure out the right index. Glad to hear you are making progress on this 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants