Ejemplo n.º 1
0
def selector_on_item_remove(e, d):
    e.preventDefault()
    tid = e.target.dataset.id
    tname = e.target.dataset.js_name
    data = this.state.selected
    if tid and data:
        tid = int(tid)
        ndata = utils.remove_from_list(data, tid, key="id")
        this.setState({'selected': ndata})
    if tname and data:
        ndata = utils.remove_from_list(data, tname, key="name")
        this.setState({'selected': ndata})
Ejemplo n.º 2
0
def remove_parody(e, d):
    e.preventDefault()
    tid = e.target.dataset.id
    tname = e.target.dataset.js_name
    data = this.props.data or this.state.data
    if tid and data:
        tid = int(tid)
        ndata = utils.remove_from_list(data, tid, key="id")
        this.update_data(ndata)
    if tname and data:
        ndata = utils.remove_from_list(data, tname, key="preferred_name.name")
        this.update_data(ndata)
Ejemplo n.º 3
0
def remove_url(e, d):
    e.preventDefault()
    tid = e.target.dataset.id
    data = this.props.data or this.state.data
    if tid and data:
        ndata = utils.remove_from_list(data, tid, index=True)
        this.update_data(ndata)
Ejemplo n.º 4
0
def selector_on_item(e, data):
    selected = this.state.selected
    selected_ids = [a.id for a in selected]
    selected_def = this.state.default_selected
    selected_ids_def = [a.id for a in selected_def]
    if data.id in selected_ids or data.id in selected_ids_def:
        selected_def = utils.remove_from_list(selected_def, data)
        selected = utils.remove_from_list(selected, data)
        if this.props.item_id:
            this.remove_item(new_data=data)
    else:
        selected = utils.JSONCopy(selected)
        selected.append(data)
        if this.props.item_id:
            this.add_item(new_data=data)

    this.setState({'selected': selected, 'default_selected': selected_def})
Ejemplo n.º 5
0
def remove_tag(e, d):
    tag = e.target.dataset.tag
    ns = e.target.dataset.namespace or '__namespace__'
    data = this.props.data or this.state.data
    if tag and ns and data:
        if isinstance(data, list) or this.props.single:
            f = None
            for t in data:
                has_ns = utils.get_object_value('namespace.name', t) == ns
                has_tag = utils.get_object_value('tag.name', t) == tag
                if has_ns and has_tag:
                    f = t
                    break
            if f:
                data = utils.remove_from_list(data, f, key=None)
        else:
            tags = data[ns]
            data[ns] = utils.remove_from_list(tags, tag, key="name")
            if not len(data[ns]):
                del data[ns]
        this.update_data(data)
Ejemplo n.º 6
0
def selector_on_item(e, data):
    selected = this.state.selected
    selected_ids = [a.id for a in selected]
    selected_def = this.props.defaultSelected
    selected_def_ids = [a.id for a in selected_def] if selected_def else []
    if data.id in selected_ids:
        selected = utils.remove_from_list(selected, data)
    if data.id in selected_def_ids:
        pass
    else:
        key = 'name'
        selected = utils.update_object(
            None,
            this.state.selected,
            data,
            op="append",
            unique=lambda a, b: a['id'] == b['id']
            if a['id'] or b['id'] else utils.get_object_value(
                key, a) == utils.get_object_value(key, b))
    this.setState({'selected': selected})
Ejemplo n.º 7
0
 'load_gallery':
 load_gallery,
 'update_options':
 update_options,
 'on_update_data':
 creategallery_on_update_data,
 'update_data':
 utils.update_data,
 'on_add_to_inbox':
 lambda e, d: all(
     (this.update_options('gallery.add_to_inbox', d.checked),
      utils.storage.set('new_gallery.add_to_inbox', d.checked))),
 'remove_page':
 lambda e, d: this.setState({
     'pages':
     utils.remove_from_list(this.state.pages, d.value, key='number')
 }),
 'on_load_gallery_submit':
 lambda e, d: this.load_gallery(),
 'set_path':
 lambda e, d: this.setState({'load_gallery_path': d.value}),
 'submit_gallery':
 submit_gallery,
 'on_gallery_submit':
 lambda: all((this.submit_gallery(), )),
 'on_submitted':
 lambda cmd: all((this.setState({
     'data': {},
     'pages': [],
     'gallery_data': {},
     'new_data': {},
Ejemplo n.º 8
0
def remove_title(e, d):
    tid = e.target.dataset.id
    data = this.props.data or this.state.data
    if tid and data:
        ndata = utils.remove_from_list(data, tid, index=True)
        this.update_data(ndata)