Forem

Matt Layman
Matt Layman

Posted on • Originally published at mattlayman.com

1

Reordering Models - Building SaaS #80

In this episode, we looked at an UpdateView for the GradeLevel model in the homeschool application. Along the way, I had to display some UI elements on the grade to give users the ability to adjust the ordering of courses within their grade level.

We started by adding the icon link that I wanted to use to give users access to the edit page. Once the link was in place, I created the URL and copied an existing view as a starting point for the UpdateView.

As I got into the development of the UpdateView, I discovered that the template and the form already existed! I had the proper form for a pre-existing CreateView. All I had to add was a bit of context data to conditionally display "Add" vs. "Update" in the UI. I also added a "Cancel" button to the view that was missing before.

Once the view was in place, I wrote all the unit tests to prove that the code worked. I do this because it acts as my safety net for future changes.

The final change that I made was to display a table of courses that the user will be able to move each course up and down. I showed some other up and down movement views from course tasks rather than showing how to implement the movement views during the stream.

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay