src/openui5-todo-app/controller/Main.controller.js
/**
       * Toggle completion stat of todo list.
       * @param {sap.ui.base.Event} [oEvent] An Event object consisting of an id, a source and a map of parameters.
       */
Toggle completion stat of todo list.
@param {sap.ui.base.Event} [oEvent] An Event object consisting of an id, a source and a map of parameters.
Toggle completion stat of todo list . @param { sap . ui . base . Event } [ oEvent ] An Event object consisting of an id a source and a map of parameters .
onTogglTodoListCompletion(oEvent) {
        const oCheckBox = oEvent.getSource()
        const isCompleted = oEvent.getParameter('selected')
        const sBindingPath = oCheckBox.getBindingContext('todo').getPath()
        const iDeleteIndex = parseInt(sBindingPath.split('/').pop(), 10)
        const oTodoModel = this.getView().getModel('todo')
        const aTodoItems = oTodoModel.getProperty('/items')
        const aNewTodoItems = aTodoItems.map(
          (oItem, iIndex) =>
            iIndex === iDeleteIndex
              ? { ...oItem, isCompleted: isCompleted }
              : oItem
        )
        oTodoModel.setProperty('/items', aNewTodoItems)
        this._updateItemsLeft()
      }
onTogglTodoListCompletion ( oEvent ) { const oCheckBox = oEvent . getSource ( ) const isCompleted = oEvent . getParameter ( 'selected' ) const sBindingPath = oCheckBox . getBindingContext ( 'todo' ) . getPath ( ) const iDeleteIndex = parseInt ( sBindingPath . split ( '/' ) . pop ( ) , 10 ) const oTodoModel = this . getView ( ) . getModel ( 'todo' ) const aTodoItems = oTodoModel . getProperty ( '/items' ) const aNewTodoItems = aTodoItems . map ( ( oItem , iIndex ) => iIndex === iDeleteIndex ? { ... oItem , isCompleted : isCompleted } : oItem ) oTodoModel . setProperty ( '/items' , aNewTodoItems ) this . _updateItemsLeft ( ) }
Toggle completion stat of todo list.
Toggle completion stat of todo list .
// update item from todo list // update todo model // update items left