template and JS refactoring for editing objects