Skip to content

Commit

Permalink
Added support for ordering flows in the drop-down
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyjb committed Mar 11, 2019
1 parent 0aaba4f commit fd8c71b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 6 deletions.
16 changes: 15 additions & 1 deletion build/content-flow.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/content-flow.min.css

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions build/content-flow.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "content-flow",
"description": "An extension to the ContentTools WYSIWYG editor to manage content flows",
"version": "0.1.2",
"version": "0.1.3",
"keywords": [
"wysiwyg",
"inline",
Expand Down
2 changes: 2 additions & 0 deletions sandbox/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ <h1>Content flow</h1>
data-cf-flow-label="Body"
data-cf-flow-max-snippets="2"
data-cf-flow-frozen
data-cf-flow-position="2"
>
<div class="content-snippet" data-cf-snippet="1" data-cf-snippet-permanent>
<p>Data snippet example: basic</p>
Expand All @@ -42,6 +43,7 @@ <h1>Content flow</h1>
class="article__related"
data-cf-flow="article-related"
data-cf-flow-label="Related"
data-cf-flow-position="1"
>
<div class="content-snippet" data-cf-snippet="3">
<p>Archive</p>
Expand Down
14 changes: 14 additions & 0 deletions src/scripts/flow-mgr.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,20 @@ class _FlowMgr extends ContentTools.ComponentUI
else
@_domFlows = @_flowQuery

# Sort the flows based on their position attribute
@_domFlows = Array.from(@_domFlows)

cmp = (a, b) ->
aPos = parseFloat(a.dataset.cfFlowPosition)
if aPos is NaN
aPos = 999999
bPos = parseFloat(b.dataset.cfFlowPosition)
if bPos is NaN
bPos = 999999
return aPos - bPos

@_domFlows.sort(cmp)

# Convert the flows found in the DOM into models and populate the
# flows UI compontent.
flows = []
Expand Down

0 comments on commit fd8c71b

Please sign in to comment.