-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #345 from dwyl/drag-drop_fix#145
[PR] Adding drag n drop and index-based reordering
- Loading branch information
Showing
28 changed files
with
1,486 additions
and
529 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
defmodule App.Cid do | ||
@moduledoc """ | ||
Helper functions for adding `cid` to records transparently in a changeset pipeline. | ||
""" | ||
|
||
@doc """ | ||
`put_cid/1` as its' name suggests puts the `cid` for the record into the `changeset`. | ||
This is done transparently so nobody needs to _think_ about cids. | ||
""" | ||
def put_cid(changeset) do | ||
# don't add a cid to a changeset that already has one | ||
if Map.has_key?(changeset.changes, :cid) do | ||
changeset | ||
else | ||
# Only add cid to changeset that has :name i.e. list.name or :text i.e. item.text | ||
if Map.has_key?(changeset.changes, :name) || | ||
Map.has_key?(changeset.changes, :text) do | ||
cid = Cid.cid(changeset.changes) | ||
%{changeset | changes: Map.put(changeset.changes, :cid, cid)} | ||
else | ||
changeset | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.