fablabbcn / smartcitizen-web

The Smart Citizen Kit platform
https://smartcitizen.me
GNU Affero General Public License v3.0
13 stars 7 forks source link

Users cannot delete a device - REMOVE button not working #422

Closed viktorsmari closed 3 years ago

viktorsmari commented 3 years ago

Expected behaviour

Device should be deleted

Actual behaviour

Button does nothing - errors in dev console

How to reproduce?

  1. Log in
  2. Go to your profile https://smartcitizen.me/profile/kits
  3. Try removing a device by clicking the REMOVE button

2020-11-26_17-28-41

Error:

TypeError: $mdDialog.confirm(...).title(...).content is not a function
    at Object.removeKit [as remove] (app-27d3da4d1b.js:5988)
    at fn (eval at compile (vendor-fec684fdfd.js:25632), <anonymous>:4:286)
    at callback (vendor-fec684fdfd.js:38165)
    at Scope.$eval (vendor-fec684fdfd.js:28607)
    at Scope.$apply (vendor-fec684fdfd.js:28706)
    at HTMLButtonElement.<anonymous> (vendor-fec684fdfd.js:38169)
    at HTMLButtonElement.dispatch (vendor-fec684fdfd.js:4435)
    at HTMLButtonElement.elemData.handle (vendor-fec684fdfd.js:4121)
    at HTMLButtonElement.d (raven.js:522) undefined
viktorsmari commented 3 years ago

Problem solved in 58dbf03c277743fa519b159980e2fbbbc422ff61 by removing the content function

oscgonfer commented 3 years ago

Hi @viktorsmari,

Trying this again in chrome, it doesn't seem to delete it either. Testing with device 13368 gives the following console error:

image

viktorsmari commented 3 years ago

Where are you deleting the kits? Which URL?

If I delete them here, it works with no console errors: https://smartcitizen.me/profile/kits

oscgonfer commented 3 years ago

Hi,

Sorry for the lack of detail, it's in the device page itself, in this case would be scrolling down, right below the graph (this would be another device, but shows where the button is):

image

viktorsmari commented 3 years ago

Turns out the method for removing kits lives in 2 places. I had only fixed one of them before.

Ideally I would refactor this into having only 1 method (DRY principle) but I don't know how to do it in AngularJS. There is probably a reason for it living in 2 places, maybe we will find out later.

Method now updated in both places :+1:

oscgonfer commented 3 years ago

Just tested it and works, great! We can close it for now and reopen when you want to refactor?