vs code power-shell doesn’t recognize npm command

My vs code power-shell doesn’t recognize my command … but cmd works just fine … What is the problem ? … i am currently working on a react js project and i am install npm and yarn then i face these problem… so how can i solve it as soon as possible or i freshly install node and others thing

Kill process.exec function

I have a function to execute a process:

static async runTest() { await process.exec(`start ${currentDir}/forward.py`); }

runTest();

The python script will continue to run until it’s killed, which I don’t know how to do at the moment. So in short, I want to kill this process manually at some point. How I would I do this? Thank you!

Is it valid to mutate an array prop in a child component?

I’ve noticed when pushing to an array that has been passed to a child component as prop, I don’t get the usual ‘Avoid mutating a prop directly’ error. After thinking about it, this makes sense because the array is a reference and if something causes the parent to re-render, the child will render correctly because of this.

Is the proper approach still to emit to the parent and have the parent operate on the array, or is it perfectly valid to operate on the array in the child component since it is a reference?

Vue – Loop through an array with nested objects

I’m fetching a list that I’m trying to loop through that has an object inside. I’m using vue and the array looks like this:

companies: [
  name: "company1"
  id: 1
  type: "finance"
  additionalData: "{"funder":"blabla","idType":5,"number":"2"}"
]

My problem is accessing the different ones inside the additionalData.

This is how far I’ve come:

        <div
            v-for="(company, idx) in companies"
            :key="idx"
        >
          <p class="font-weight-bold text-h6"> {{ company.name }} </p>
          <p class="font-weight-bold"> {{ company.additionalData.funder }} </p>
        </div>

This doesn’t work and I’ve tried a loop inside the loop aswell. When I only print out {{ company.additionalData }} I get the whole object. Can it have something to do with that the object is inside a string? Could I do a computed or something to figure this out or? 🙂

Define characters in a string

I want to be able to reserve 2 or more characters in a string. For example:

let string = "  "
string.unknownMethod("a")

What function do I need in place of unknown method to get this output " a". But if string.unknownMethod("ab") the output should be "ab"

Remove sorting from Datatable in checkboxes

var table = $('#mytable').DataTable({
      'columnDefs': [{
         'targets': 0,
         'searchable': false,
         'orderable': false,
         'className': 'checkbox check-success'  
      }],
      'order': [[1, 'asc']]
   });
                                                                <div class="checkbox check-success">

                                                                    <label class=" mt-checkbox mt-checkbox-outline"
                                                                        for="checkbox_<?php echo $valuep['0'] ;?>">
                                                                        <input id="checkbox_<?php echo $valuep['0'] ;?>" type="checkbox" name="leads_ids" value="<?php echo $valuep['0'] ;?>" class="select_click">
                                                                        <span></span>
                                                                    </label>
                                                                    <input type="hidden" id="enable_all"
                                                                        name="enable_all" value="1">
                                                                    <input type="hidden" id="lead_contact_id_<?php echo $valuep['0'] ;?>"
                                                                        name="contact_id" value="<?php echo $valuep['0'] ;?>">

                                                                </div>
                                                                <span id="custom_controls"></span>
                                                            </td>

Whenever I click on select-all on top of table it gets back to first page.I need to select some rows in table and export it to csv but when selecting on different pages when i click on select all it gets back to page 1.

Javascript – Sort columns in table by date while rows content changes

I have a table/Div like the one below, and the data is generated dynamically in real time so the rows keep coming and changing.

The table is floating on my browser, I dont have control over the source website so I cannot use jquery to modify the table. I can ONLY use javascript, (by using the browser extension) to alter the DOM.

I need the javascript code that can:

  • sort the table by the date and time – newest on top
  • highlight rows that have the word: “blocked”
  • hide rows that have the word: “unknown” (but make the rows appear when the content is changed to something else)
  • keep sorting when timeCell or descriptionCell is updated in any row (or maybe run the sorting every 30 seconds)

I am not familiar with the modern JS code but I think that the date time can be changed to unix timestamp so it make the sorting easier.

I tried to use Chrome browser extension called: Javascript Injector and some javascript code that uses const, i.e: const tabledoc = document;

But when I click the update button of the extension, it will show me some error that says tabledoc is already defined.

Can you please help me?

<div class="container-QqYJdG">

<div class="wrapper-QqYJdG">
  <div class="bodyRow-3OfxA">
    <div class="cell-3OfxA symbolCell-3OfxA">
      <div class="Name-3OfxA">MacKenzi</div>
    </div>
    <div class="cell-3OfxA descriptionCell-3OfxA">visited</div>
    <div class="cell-3OfxA timeCell-3OfxA"><span>1/11/2022</span><span>1:59:08 PM</span></div>
  </div>
  <div class="bodyRow-3OfxA">
    <div class="cell-3OfxA symbolCell-3OfxA">
      <div class="Name-3OfxA">Sophia</div>
    </div>
    <div class="cell-3OfxA descriptionCell-3OfxA">visited</div>
    <div class="cell-3OfxA timeCell-3OfxA"><span>1/11/2022</span><span>12:10:00 AM</span></div>
  </div>
  <div class="bodyRow-3OfxA">
    <div class="cell-3OfxA symbolCell-3OfxA">
      <div class="Name-3OfxA">Luc</div>
    </div>
    <div class="cell-3OfxA descriptionCell-3OfxA">visited</div>
    <div class="cell-3OfxA timeCell-3OfxA"><span>1/11/2022</span><span>12:40:02 AM</span></div>
  </div>

    <div class="bodyRow-3OfxA">
    <div class="cell-3OfxA symbolCell-3OfxA">
      <div class="Name-3OfxA">Daniel</div>
    </div>
    <div class="cell-3OfxA descriptionCell-3OfxA">status: unknown</div>
    <div class="cell-3OfxA timeCell-3OfxA"><span>1/11/2022</span><span>12:32:02 AM</span></div>
  </div>

    <div class="bodyRow-3OfxA">
    <div class="cell-3OfxA symbolCell-3OfxA">
      <div class="Name-3OfxA">Michael</div>
    </div>
    <div class="cell-3OfxA descriptionCell-3OfxA">is blocked</div>
    <div class="cell-3OfxA timeCell-3OfxA"><span>1/11/2022</span><span>12:49:02 AM</span></div>
  </div>

  <div class="bodyRow-3OfxA">
    <div class="cell-3OfxA symbolCell-3OfxA">
      <div class="Name-3OfxA">Vova</div>
    </div>
    <div class="cell-3OfxA descriptionCell-3OfxA">visited</div>
    <div class="cell-3OfxA timeCell-3OfxA"><span>1/11/2022</span><span>3:02:01 PM</span></div>
  </div>
</div>

</div>

Building a todo app in React, used filters but need a way to make sure “complete” button only removes one task instead of two

I’m new to learning react so I followed this tutorial https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Client-side_JavaScript_frameworks/React_components to create a todo app and then tweaked it to fit the requirements of the project I’m working on. Everything works the way it should except when I delete (complete) things from the associate side, it also deletes it from my main side as well. I understand the general concept of why that’s happening (I don’t have two separate lists in my code), just not sure how to go about fixing it without removing the filter I have in place. I had tried to implement a separate list for those tasks but just wasn’t understanding how to go about it.

App.js

const FILTER_MAP = {
  All: () => true,
  Associate: task => task.checked 
};
const FILTER_NAMES = Object.keys(FILTER_MAP);

function App(props) {

  const [tasks, setTasks] = useState(props.tasks);
  const [filter, setFilter] = useState('All');

  function toggleTaskChecked(id) {
    const updatedTasks = tasks.map(task => {
      if (id === task.id) {
        return {...task, checked: !task.checked}
      }
      return task;
    });
    setTasks(updatedTasks);
  }

  function completeTask(id) {
    const remainingTasks = tasks.filter(task => id !== task.id);
    setTasks(remainingTasks);
  }

  const taskList = tasks
    .filter(FILTER_MAP[filter])
    .map(task => (
      <Todo
        id={task.id}
        name={task.name}
        checked={task.checked}
        key={task.id}
        toggleTaskChecked={toggleTaskChecked}
        completeTask={completeTask}
      />
    ));

  const filterList = FILTER_NAMES.map(name => (
    <FilterButton
    key={name}
    name={name}
    isPressed={name === filter}
    setFilter={setFilter}
  />
  ));

  function addTask(name) {
    const newTask = { id: "todo-" + nanoid(), name: name, checked: false };
    setTasks([...tasks, newTask]);
  }

  return (
    <div className="app">
      <h1 className = "tasks-header">Task Tracker</h1>
      <Form addTask={addTask}/>
      <div className="list-buttons">
        {filterList}
      </div>
      <ul
        role="list"
        className="todo-list"
        aria-labelledby="list-heading"
      >
        {taskList}
      </ul>
    </div>
  );

}

export default App

Todo.js

export default function Todo(props) {

  return (
    <li className="todo stack-small">
      <div className="c-cb">
        <input id={props.id} 
        type="checkbox" 
        defaultChecked={props.checked}
        onChange={() => props.toggleTaskChecked(props.id)} 
        />
        <label className="todo-label" htmlFor="todo-0">
          {props.name}
        </label>
      </div>
      <div className="btn-group">
        <button type="button" 
        className="complete-button"
        onClick={() => props.completeTask(props.id)}
        >
          Complete 
        </button>
      </div>
    </li>
  );
  }

index.js

const DATA = [
  { id: "todo-0", name: "Brush Teeth", checked: false },
  { id: "todo-1", name: "Make Dinner", checked: false },
  { id: "todo-2", name: "Walk Dog", checked: false },
  { id: "todo-3", name: "Run Reports", checked: false },
  { id: "todo-4", name: "Visit Mom", checked: false },
  { id: "todo-5", name: "Aerobics", checked: false },
  { id: "todo-6", name: "Project", checked: false },
  { id: "todo-7", name: "Lecture", checked: false },
  { id: "todo-8", name: "Have Lunch", checked: false }
];

ReactDOM.render(
  <React.StrictMode>
    <App tasks={DATA}/>
  </React.StrictMode>,
  document.getElementById('root')
);

FilterButton.js

function FilterButton(props) {
    return (
      <button
        type="button"
        className="toggle-btn"
        aria-pressed={props.isPressed}
        onClick={() => props.setFilter(props.name)}
      >
        <span className="visually-hidden">Show </span>
        <span>{props.name}</span>
        <span className="visually-hidden"> Tasks</span>
      </button>
    );
  }

export default FilterButton;

How to get yup.string() to require string of any length greater than 3 or empty

i want to update a list of field data with formik.
i have this validation

validationSchema: Yup.object().shape({
      password: Yup.string()
        .min(4, 'Password must be at least 4 characters.')
        .required('Password must be at least 4 characters.'),
      ....
    }),

i want the user to be able to set password at least a length of 4 and if the user does not enter password then submit as empty string.
password component

<FormControl
              fullWidth
              error={Boolean(formik.touched.password && formik.errors.password)}
              variant="outlined"
            >
              <InputLabel htmlFor="password">Password</InputLabel>
              <OutlinedInput
                id="password"
                name="password"
                inputProps={{
                  autoComplete: 'password',
                  form: {
                    autoComplete: 'off',
                  },
                }}
                type={showPassword ? 'text' : 'password'}
                onBlur={formik.handleBlur}
                onChange={formik.handleChange}
                value={formik.values.password}
                endAdornment={
                  <InputAdornment position="end">
                    <IconButton
                      aria-label="toggle password visibility"
                      onClick={() => setShowPassword(!showPassword)}
                      onMouseDown={(event) => event.preventDefault()}
                      edge="end"
                    >
                      {showPassword ? <VisibilityOff /> : <Visibility />}
                    </IconButton>
                  </InputAdornment>
                }
                label="Password"
              />
              {formik.errors.password && <FormHelperText>{formik.errors.password}</FormHelperText>}
            </FormControl>

but with this code, if the password field is touched but not entered any password formik is not letting to submit the data. how can I do that? thank u in advance.

Negative vw value is not recognized in translateX(-100vw)

I am using css transitions and a little javascript to make elements slide into the page from the left or right.

From the right side (starting from transform: translateX(100vw);) it works perfectly fine.
But from the left side (negative translate value: transform: translateX(-100vw);) it does not work at all. There is no error, but the element just pops up at the end of the transition without any “animated” movement.

If I use a px value instead of vw for the negative/ left side, it also works fine. I found several examples where people used negative vw values and did not seem to have problems with it…

I also tried transform: translateX(calc(0px - 100vw));. No luck…

(I am not using any libraries etc.)

<!-- HTML -->

<div class="container">
  <div class="slide-in l"></div>
  <div class="slide-in r"></div>
</div>
/* CSS */

.slide-in {
  transition: transform 0.8s ease;
}
.slide-in.l {
  transform: translateX(-100vw); /* this is the line does not work */
}
.slide-in.r {
  transform: translateX(100vw);
}
.slide-in.show {
  transform: translateX(0);
}
/* JavaScript */

const slider = document.querySelectorAll('.slide-in');

window.addEventListener("load", () => {
    slider.forEach(s => {
        s.classList.add('show');
    })
});

Any ideas what could be the problem?

Showing Error “argument is not defined” while adding multiple arguments in arrow function but It’s Working in Normal Function call

//Example – 1

function add1(){

    if (arguments.length == 0){

        document.write("NO Argument Passed!");
    }
    else{

        let sum = 0;

        for(let num in arguments){

            sum += arguments[num];
        }

        document.write(sum);
    }
}

add1(5,10); 

In this example, I am getting the correct result.

//Example – 2 ( With Arrow Function)

let sum = () => {

    if( arguments.length == 0){

        document.write("NO Argument Passed!");
    }
    else{

        let sum1 = 0;

        for(let number in arguments){

            sum1 += arguments[number];
        }

        document.write(sum1);
    }


};

sum(10,20);

*Here I am getting an error in console “arguments is not defined”. Please tell me where I did Wrong.Thank you..!

TypeError: t.message.apply is not a function

I am receiving this error and am not sure why I’m receiving it. I have no function named “message”.

Receiving and sending messages works fine for my local environment, but not when I test it live. Is there a something I am missing here? I’m assuming this is the problem (or is that not the case?)

Vue file –

<template>
  <div class="modal-container">
    <v-dialog v-model="dialog" width="450">
      <v-card data-test="direct-messaging-button">
        <header>
          <h4>Communicating with: {{ phoneNumber }}</h4>
        </header>
        <section class="chat-box">
          <div class="chat-box-list-container" ref="chatbox">
            <ul class="chat-box-list">
              <li class="message"
                  v-for="(message, idx) in messages"
                  :key="idx"
                  :class="message.author">
                <p>
                  <span>{{ message.text }}</span>
                </p>
              </li>
            </ul>
          </div>
        </section>
        <footer>
          <form @submit.prevent="message">
            <input
                type="text"
                v-model="message"
                placeholder="Write a message..." />
            <input
                class="submit_btn"
                @click="submitMessage(); apiGroup();"
                type="submit"
                value="Send" />
          </form>
        </footer>
      </v-card>
    </v-dialog>
  </div>
</template>


<script lang="ts">
import Vue from 'vue'
import store from "@/store";
import axios from 'axios'

export default Vue.extend({
  name: "A2PMessagingModal",
  data() {
    return {
      message: '',
      messages: [],
      phoneNumber: ''
    }
  },
  mounted() {},
  methods: {
    apiGroup() {
      setInterval(() => {
        this.receiveMessage();
      }, 5000);
    },
    async submitMessage() {
      this.messages.push({
        text: this.message,
        author: 'sender'
      })
      let formData = new FormData;
      formData.set('message', this.message)
      axios.post(`api/v1/message/a2pMessaging`, formData)
          .then(res => {
            console.log(res.data)
            this.phoneNumber = store.state.location.phoneNumber;
            this.message = '';
          })
          .catch(error => {
            alert(error.response.data.errors);
          })
    },
    async receiveMessage() {
      axios.get(`/api/v1/message/a2pMessageReceiver`)
          .then(res => {
            if("+1"+store.state.location.phoneNumber === res.data.originationNumber) {
              this.messages.push({
                author: 'respondent',
                text: res.data.messageBody
              })
            } else {
              this.messages.push({
                text: null
              })
            }
          })
    },
  },
  computed: {
    dialog() {
      return store.state.location.showA2PMessagingModal
    },
    cancel() {
      store.commit('location/showA2PMessagingModal', false)
    }
  }
})

</script>

Select row-index value by span text

how can I make a selector or an algorithm to return the row-index value with the text of a span?

Html code:

<div class="container">
<div row-index="0">
   <div>
      <div>
         <span>
            <div>
               <span>
               Test1234
               </span>
            </div>
         </span>
      </div>
   </div>
</div>
<div row-index="1">
   <div>
      <div>
         <span>
            <div>
               <span>
               1234test
               </span>
            </div>
         </span>
      </div>
   </div>
</div>
</div>

Expected result: getIndex(“1234test”); //will return 1 because row-index=’1′

Everything I tried did not help me get to the final solution, will you be able to suggest a solution or give me some advice? I really don’t even know where to start

Creating an application angular

Create an application with the following functionality

1 Input fields should be Start Point and End Point.

  1. Design should have the first three characters of starting point and ending point

  2. Functionality:

  3. If it’s a continued trip (Eg. Bangalore to Chennai, Chennai to Ooty) then the straight line should be on level 1

2 If it’s not a continued trip (Eg Bangalore to Chennai, Ooty to Bangalore) then the straight line should have an arrow and be on level 1.

  1. If consecutive trips have the same pickup and drop location then those to be in Level 2

  2. Any number of trips can be added and design should respond accordingly to adjust within the defined dimension