Giter Site home page Giter Site logo

Comments (4)

irossimoline avatar irossimoline commented on June 30, 2024 1

Hi @hossameldeen,

I think you have found an issue. The thing is that originalData could be undefined, but currentData shouldn't: the first one is only populated when editing an element, and the last one is the one that holds the row data, so it should not be undefined. I'm not with my PC near now, but I can fix it and push soon.

from angular4-material-table.

irossimoline avatar irossimoline commented on June 30, 2024 1

Hi @hossameldeen,

I've published a new version with this fix. :)
If you have any question please let me know.

from angular4-material-table.

hossameldeen avatar hossameldeen commented on June 30, 2024 1

@irossimoline , I was writing this comment when you pushed the fix :-) Thanks for the prompt response and for the awesome package!

I've checked it, will upgrade. Nope, no more questions 👍 , you can close.

By the way, I'm a fan of strictNullChecks. So, I've tried to enable it on your project and resolve the errors. One error that particularly caught my eye is this:

  cancelOrDelete(): void {
    if (this.id == -1 || !this.editing)
      this.delete();
    else {
      this.currentData = this.originalData; // I've made currentData required while originalData optional, so an error came up here for assigning optional to required
      this.editing = false;
      this.validator.disable();
    }
  }

Of course, the if-condition above !this.editing makes sure that we're in editing mode in the other branch & thus have originalData. But how to make sure that editing == true -implies-> originalData !== undefined across the whole code?

For the purposes of technical curiosity, I've made a solution & reached it to passing compilation (didn't even test). I probably don't recommend merging it into the package since it'll break backward compatibility and may need a bit refactoring. But anyway, I'm opening a PR with it in case you want to check it out :-)

Thanks again :-)

from angular4-material-table.

irossimoline avatar irossimoline commented on June 30, 2024 1

Cool @hossameldeen!

I'm gonna close this issue, and lets talk about the code improvement proposed directly on the PR.
Thank you in advance for contributing with this project! 😃

from angular4-material-table.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.