git.s-ol.nu mmm / 16232a2
add fileder ordering in stores.web, fileder, browser s-ol 3 years ago
4 changed file(s) with 26 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
137137 @store\update_facet path, facet.name, facet.type, value
138138 200, 'ok'
139139 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}"
141152 when 'DELETE'
142153 if facet
143154 @store\remove_facet path, facet.name, facet.type
174185
175186 res = headers.new!
176187 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'
179191 res\append ':status', tostring status
180192 res\append 'content-type', response_type
181193
278278 span '- ', (link_to child, code name), style: flex: 1
279279
280280 button '↑', disabled: i == 1, onclick: (_, e) ->
281 fileder\reorder_child name, i - 1
281 fileder\swap_children i, i - 1
282282 @refresh true
283283
284284 button '↓', disabled: i == num, onclick: (_, e) ->
285 fileder\reorder_child name, i + 1
285 fileder\swap_children i, i + 1
286286 @refresh true
287287
288288 button 'rm', onclick: (_, e) ->
7878
7979 __newindex: (t, k, child) ->
8080 rawset t, k, child
81 return if child.path
8182
8283 if @path == '/'
8384 child\mount '/'
317318 assert removed, "no such child fileder"
318319 @store\remove_fileder removed.path
319320
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
320326 __tostring: => "Fileder:#{@path}"
321327
322328 {
7676 @log "moving fileder #{path} -> #{next_parent}/"
7777 error "not implemented"
7878
79 swap_fileders: (parent, child_a, child_b) =>
80 req 'PUT', "#{@host .. parent}/", "swap\n#{child_a}\n#{child_b}"
81
7982 -- facets
8083 list_facets: (path) =>
8184 coroutine.wrap ->