add fileder ordering in stores.web, fileder, browser
s-ol
3 years ago
137 | 137 |
@store\update_facet path, facet.name, facet.type, value
|
138 | 138 |
200, 'ok'
|
139 | 139 |
else
|
140 | |
501, "not implemented"
|
|
140 |
cmd, args = value\match '^([^\n]+)\n(.*)'
|
|
141 |
switch cmd
|
|
142 |
when 'swap'
|
|
143 |
child_a, child_b = args\match '^([^\n]+)\n([^\n]+)$'
|
|
144 |
assert child_a and child_b, "invalid arguments"
|
|
145 |
|
|
146 |
@store\swap_fileders path, child_a, child_b
|
|
147 |
200, 'ok'
|
|
148 |
when nil
|
|
149 |
400, "invalid request"
|
|
150 |
else
|
|
151 |
501, "unknown command #{cmd}"
|
141 | 152 |
when 'DELETE'
|
142 | 153 |
if facet
|
143 | 154 |
@store\remove_facet path, facet.name, facet.type
|
|
174 | 185 |
|
175 | 186 |
res = headers.new!
|
176 | 187 |
response_type = if status > 299 then 'text/plain'
|
177 | |
else if facet.type == 'text/html+interactive' then 'text/html'
|
178 | |
else facet.type
|
|
188 |
else if facet and facet.type == 'text/html+interactive' then 'text/html'
|
|
189 |
else if facet then facet.type
|
|
190 |
else 'text/plain'
|
179 | 191 |
res\append ':status', tostring status
|
180 | 192 |
res\append 'content-type', response_type
|
181 | 193 |
|
278 | 278 |
span '- ', (link_to child, code name), style: flex: 1
|
279 | 279 |
|
280 | 280 |
button '↑', disabled: i == 1, onclick: (_, e) ->
|
281 | |
fileder\reorder_child name, i - 1
|
|
281 |
fileder\swap_children i, i - 1
|
282 | 282 |
@refresh true
|
283 | 283 |
|
284 | 284 |
button '↓', disabled: i == num, onclick: (_, e) ->
|
285 | |
fileder\reorder_child name, i + 1
|
|
285 |
fileder\swap_children i, i + 1
|
286 | 286 |
@refresh true
|
287 | 287 |
|
288 | 288 |
button 'rm', onclick: (_, e) ->
|
78 | 78 |
|
79 | 79 |
__newindex: (t, k, child) ->
|
80 | 80 |
rawset t, k, child
|
|
81 |
return if child.path
|
81 | 82 |
|
82 | 83 |
if @path == '/'
|
83 | 84 |
child\mount '/'
|
|
317 | 318 |
assert removed, "no such child fileder"
|
318 | 319 |
@store\remove_fileder removed.path
|
319 | 320 |
|
|
321 |
swap_children: (ia, ib) =>
|
|
322 |
a, b = @children[ia], @children[ib]
|
|
323 |
@store\swap_fileders @path, (a\gett 'name: alpha'), (b\gett 'name: alpha')
|
|
324 |
@children[ia], @children[ib] = b, a
|
|
325 |
|
320 | 326 |
__tostring: => "Fileder:#{@path}"
|
321 | 327 |
|
322 | 328 |
{
|
76 | 76 |
@log "moving fileder #{path} -> #{next_parent}/"
|
77 | 77 |
error "not implemented"
|
78 | 78 |
|
|
79 |
swap_fileders: (parent, child_a, child_b) =>
|
|
80 |
req 'PUT', "#{@host .. parent}/", "swap\n#{child_a}\n#{child_b}"
|
|
81 |
|
79 | 82 |
-- facets
|
80 | 83 |
list_facets: (path) =>
|
81 | 84 |
coroutine.wrap ->
|