fix warning "no-loop-func"
This commit is contained in:
parent
5044b09701
commit
1d3f356fe7
@ -169,35 +169,37 @@ export const setSubmitError = () => (dispatch, getState) => {
|
|||||||
if(builder.id === undefined || builder.title === ''){
|
if(builder.id === undefined || builder.title === ''){
|
||||||
dispatch(setError(undefined, 'title'));
|
dispatch(setError(undefined, 'title'));
|
||||||
}
|
}
|
||||||
for(var i = 0; i < builder.steps.length; i++){
|
builder.steps.map((step, i) => {
|
||||||
builder.steps[i].id = i+1;
|
step.id = i+1;
|
||||||
if(i === 0){
|
if(i === 0){
|
||||||
if(builder.steps[i].requirements && builder.steps[i].requirements.length > 0){
|
if(step.requirements && step.requirements.length > 0){
|
||||||
var requirements = builder.steps[i].requirements.filter(requirement => typeof(requirement)==='number');
|
var requirements = step.requirements.filter(requirement => typeof(requirement)==='number');
|
||||||
if(requirements.length < builder.steps[i].requirements.length){
|
if(requirements.length < step.requirements.length){
|
||||||
dispatch(changeContent(i, 'requirements', requirements));
|
dispatch(changeContent(i, 'requirements', requirements));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(builder.steps[i].hardware === undefined || builder.steps[i].hardware.length < 1){
|
if(step.hardware === undefined || step.hardware.length < 1){
|
||||||
dispatch(setError(i, 'hardware'));
|
dispatch(setError(i, 'hardware'));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
var hardwareIds = data.map(hardware => hardware.id);
|
var hardwareIds = data.map(hardware => hardware.id);
|
||||||
var hardware = builder.steps[i].hardware.filter(hardware => hardwareIds.includes(hardware));
|
var hardware = step.hardware.filter(hardware => hardwareIds.includes(hardware));
|
||||||
if(hardware.length < builder.steps[i].hardware.length){
|
if(hardware.length < step.hardware.length){
|
||||||
dispatch(changeContent(i, 'hardware', hardware));
|
dispatch(changeContent(i, 'hardware', hardware));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(builder.steps[i].headline === undefined || builder.steps[i].headline === ''){
|
if(step.headline === undefined || step.headline === ''){
|
||||||
dispatch(setError(i, 'headline'));
|
dispatch(setError(i, 'headline'));
|
||||||
}
|
}
|
||||||
if(builder.steps[i].text === undefined || builder.steps[i].text === ''){
|
if(step.text === undefined || step.text === ''){
|
||||||
dispatch(setError(i, 'text'));
|
dispatch(setError(i, 'text'));
|
||||||
}
|
}
|
||||||
}
|
return null;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const checkError = () => (dispatch, getState) => {
|
export const checkError = () => (dispatch, getState) => {
|
||||||
dispatch(setSubmitError());
|
dispatch(setSubmitError());
|
||||||
var error = getState().builder.error;
|
var error = getState().builder.error;
|
||||||
|
@ -2,7 +2,6 @@ import * as Blockly from 'blockly/core';
|
|||||||
import { getColour } from '../helpers/colour';
|
import { getColour } from '../helpers/colour';
|
||||||
import * as Types from '../helpers/types'
|
import * as Types from '../helpers/types'
|
||||||
import { FieldSlider } from '@blockly/field-slider';
|
import { FieldSlider } from '@blockly/field-slider';
|
||||||
import { Field } from '..';
|
|
||||||
|
|
||||||
|
|
||||||
Blockly.Blocks['sensebox_display_beginDisplay'] = {
|
Blockly.Blocks['sensebox_display_beginDisplay'] = {
|
||||||
@ -250,4 +249,4 @@ Blockly.Blocks['sensebox_display_drawRectangle'] = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
LOOP_TYPES: ['sensebox_display_show'],
|
LOOP_TYPES: ['sensebox_display_show'],
|
||||||
};
|
};
|
||||||
|
@ -5,30 +5,29 @@ import tutorials from '../data/tutorials.json';
|
|||||||
const initialStatus = () => {
|
const initialStatus = () => {
|
||||||
if(window.localStorage.getItem('status')){
|
if(window.localStorage.getItem('status')){
|
||||||
var status = JSON.parse(window.localStorage.getItem('status'));
|
var status = JSON.parse(window.localStorage.getItem('status'));
|
||||||
var existingTutorialIds = [];
|
var existingTutorialIds = tutorials.map((tutorial, i) => {
|
||||||
for(var i = 0; i < tutorials.length; i++){
|
var tutorialsId = tutorial.id;
|
||||||
var tutorialsId = tutorials[i].id
|
var statusIndex = status.findIndex(status => status.id === tutorialsId);
|
||||||
existingTutorialIds.push(tutorialsId);
|
if(statusIndex > -1){
|
||||||
if(status.findIndex(status => status.id === tutorialsId) > -1){
|
var tasks = tutorial.steps.filter(step => step.type === 'task');
|
||||||
var tasks = tutorials[i].steps.filter(step => step.type === 'task');
|
var existingTaskIds = tasks.map((task, j) => {
|
||||||
var existingTaskIds = [];
|
var tasksId = task.id;
|
||||||
for(var j = 0; j < tasks.length; j++){
|
if(status[statusIndex].tasks.findIndex(task => task.id === tasksId) === -1){
|
||||||
var tasksId = tasks[j].id;
|
|
||||||
existingTaskIds.push(tasksId);
|
|
||||||
if(status[i].tasks.findIndex(task => task.id === tasksId) === -1){
|
|
||||||
// task does not exist
|
// task does not exist
|
||||||
status[i].tasks.push({id: tasksId});
|
status[statusIndex].tasks.push({id: tasksId});
|
||||||
}
|
}
|
||||||
}
|
return tasksId;
|
||||||
|
});
|
||||||
// deleting old tasks which do not longer exist
|
// deleting old tasks which do not longer exist
|
||||||
if(existingTaskIds.length > 0){
|
if(existingTaskIds.length > 0){
|
||||||
status[i].tasks = status[i].tasks.filter(task => existingTaskIds.indexOf(task.id) > -1);
|
status[statusIndex].tasks = status[statusIndex].tasks.filter(task => existingTaskIds.indexOf(task.id) > -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
status.push({id: tutorialsId, tasks: new Array(tutorials[i].steps.filter(step => step.type === 'task').length).fill({})});
|
status.push({id: tutorialsId, tasks: new Array(tutorial.steps.filter(step => step.type === 'task').length).fill({})});
|
||||||
}
|
}
|
||||||
}
|
return tutorialsId;
|
||||||
|
});
|
||||||
// deleting old tutorials which do not longer exist
|
// deleting old tutorials which do not longer exist
|
||||||
if(existingTutorialIds.length > 0){
|
if(existingTutorialIds.length > 0){
|
||||||
status = status.filter(status => existingTutorialIds.indexOf(status.id) > -1);
|
status = status.filter(status => existingTutorialIds.indexOf(status.id) > -1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user