Esempio n. 1
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)
Esempio n. 2
0
def open_external(e, d):
    e.preventDefault()
    if this.state.data:
        client.call_func("open_gallery",
                         None,
                         item_id=this.state.data.id,
                         item_type=this.state.item_type)
Esempio n. 3
0
def collection_favorite(e, d):
    e.preventDefault()
    this.setState({'fav': d.rating})
    if this.state.edit_mode:
        this.update_data(bool(d.rating), "metatags.favorite")
    else:
        this.update_metatags({'favorite': bool(d.rating)})
        this.get_item(only_gallery=True, force=True)
Esempio n. 4
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)
Esempio n. 5
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})
Esempio n. 6
0
def gallery_rate(e, d):
    e.preventDefault()
    rating = d.rating
    if this.state.data.id:
        client.call_func("update_item",
                         item_type=this.state.item_type,
                         item={
                             'id': this.state.data.id,
                             'rating': rating
                         })
    this.setState(
        {'data': utils.update_object("rating", this.state.data, rating)})
    this.get_item()
Esempio n. 7
0
def tag_on_input(e):
    if e.key == 'Enter':
        e.preventDefault()
        idata = this.state.tags_input
        itags = [x.strip() for x in str(idata).split(',')]

        data = this.props.data or this.state.data or {}
        special_namespace = "__namespace__"
        is_list = isinstance(data, list) or this.props.single
        nstag_names = []
        if is_list:
            for t in data:
                t_ns = utils.get_object_value('namespace.name', t)
                t_tag = utils.get_object_value('tag.name', t)
                nstag_names.append(t_ns + t_tag)

        for t in itags:
            if ':' in t:
                t = t.split(':', 1)
                ns = t[0].strip().capitalize() or None
                tag = t[1]
            else:
                ns = None
                tag = t

            if not tag:
                continue

            tag = tag.strip().lower()

            tag = {'name': tag}

            if is_list:
                nstag = {'tag': tag,
                         'namespace': {'name': ns or special_namespace}}
                nstag_name = nstag['namespace']['name'] + nstag['tag']['name']
                if nstag_name not in nstag_names:
                    nstag_names.append(nstag_name)
                    data = utils.update_object(None, data, nstag, op="append")
            else:
                data = utils.update_object(ns or special_namespace,
                                           data,
                                           tag,
                                           op="append",
                                           create_value=[],
                                           unique=lambda a, b: a['name'] == b['name'])

        this.setState({'tags_input': ''})
        this.update_data(data)
Esempio n. 8
0
def gallery_rate(e, d):
    e.preventDefault()
    rating = d.rating
    if this.state.edit_mode:
        this.update_data(rating, "rating")
    else:
        if this.state.data.id:
            client.call_func("update_item",
                             item_type=this.state.item_type,
                             item={
                                 'id': this.state.data.id,
                                 'rating': rating
                             })
        this.setState(
            {'data': utils.update_object("rating", this.state.data, rating)})
        this.get_item(only_gallery=True, force=True)
Esempio n. 9
0
def on_search(e, d):
    e.preventDefault() if e else None
    if e is not None:
        d = this.search_data
    if this.props.query and this.props.history:
        utils.go_to(this.props.history, query={'search': d})
    if this.props.on_search:
        o = {
            'regex': 'regex',
            'case': 'case_sensitive',
            'whole': 'match_whole_words',
            'all': 'match_all_terms',
            'desc': 'descendants',
        }
        __pragma__("iconv")
        options = {}
        for k in o:
            options[o[k]] = this.state[k]
        __pragma__("noiconv")
        this.props.on_search(d, options)
Esempio n. 10
0
def editnumber_on_key(e):
    if e.key == 'Enter':
        e.preventDefault()
        this.on_submit()
Esempio n. 11
0
def on_rate(e, d):
    e.preventDefault()
    rating = d.rating
    if this.props.edit_mode:
        this.update_data(rating, "rating")
Esempio n. 12
0
def item_favorite(e, d):
    e.preventDefault()
    # if this.props.edit_mode:
    #    this.update_data(bool(d.rating), "metatags.favorite")
    # else:
    this.update_metatags({'favorite': bool(d.rating)})
Esempio n. 13
0
                                'submitted_data': False,
                                'send_to_recycle': True,
                                'visible_gallery_cfg': False,
                                },

    'update_metatags': update_metatags,
    'update_data': utils.update_data,
    'update_menu': update_menu,
    'update_item': update_item,
    'get_item': get_item,
    'get_category': get_category,

    'favorite': collection_favorite,

    'send_to_library': lambda e, d: all((this.update_metatags({'inbox': False}),
                                         e.preventDefault())),
    'send_to_trash': lambda e, d: all((this.update_metatags({'trash': True}),
                                       e.preventDefault())),
    'restore_from_trash': lambda e, d: all((this.update_metatags({'trash': False}),
                                            e.preventDefault())),

    'on_edit': lambda e, d: all((this.setState({'edit_mode': True, 'new_data': {}, 'submitted_data': False, 'old_data': utils.JSONCopy(this.state.data)}), )),
    'on_cancel_edit': lambda e, d: all((this.setState({'data': this.state.old_data}) if this.state.old_data else None, this.setState({'edit_mode': False, 'old_data': None}))),
    'on_save_edit': lambda e, d: all((this.setState({'edit_mode': False, 'submitted_data': True, 'old_data': None}),
                                      this.update_item(), this.get_item(only_gallery=True, force=True))),

    'toggle_galleries_config': lambda a: this.setState({'visible_gallery_cfg': not this.state.visible_gallery_cfg}),

    'componentWillMount': lambda: all(((this.get_item() if not this.state.data else None),
                                       this.update_menu(),
                                       )),
Esempio n. 14
0
 get_config,
 'update_metatags':
 galleryitem.update_metatags,
 'open_external':
 galleryitem.open_external,
 'read_event':
 galleryitem.read_event,
 'update_data':
 utils.update_data,
 'favorite':
 gallery_favorite,
 'rate':
 gallery_rate,
 'send_to_library':
 lambda e, d: all(
     (this.update_metatags({'inbox': False}), e.preventDefault())),
 'send_to_trash':
 lambda e, d: all(
     (this.update_metatags({'trash': True}), e.preventDefault())),
 'restore_from_trash':
 lambda e, d: all(
     (this.update_metatags({'trash': False}), e.preventDefault())),
 'read_later':
 lambda e, d: all(
     (this.update_metatags({'readlater': True}), e.preventDefault())),
 'on_edit':
 lambda e, d: all((this.setState({
     'edit_mode': True,
     'new_data': {},
     'submitted_data': False,
     'old_data': utils.JSONCopy(this.state.data)
Esempio n. 15
0
def artist_favorite(e, d):
    if this.props.edit_mode:
        e.preventDefault()
        this.update_data(bool(d.rating), "metatags.favorite")
    elif this.props.on_favorite:
        this.props.on_favorite(e, d)
Esempio n. 16
0
 get_collection_data,
 'get_same_artist_data':
 get_same_artist_data,
 'get_config':
 get_config,
 'update_metatags':
 galleryitem.update_metatags,
 'open_external':
 galleryitem.open_external,
 'read_event':
 galleryitem.read_event,
 'favorite':
 lambda e, d: all(
     (this.update_metatags({'favorite': bool(d.rating)}),
      this.setState({'fav': d.rating}),
      this.get_item(only_gallery=True, force=True), e.preventDefault())),
 'send_to_library':
 lambda e, d: all(
     (this.update_metatags({'inbox': False}), e.preventDefault())),
 'send_to_trash':
 lambda e, d: all(
     (this.update_metatags({'trash': True}), e.preventDefault())),
 'restore_from_trash':
 lambda e, d: all(
     (this.update_metatags({'trash': False}), e.preventDefault())),
 'read_later':
 lambda e, d: all(
     (this.update_metatags({'readlater': True}), e.preventDefault())),
 'on_read':
 lambda e, d: all(
     (this.read_event(e, d), this.open_external(e, d)
Esempio n. 17
0
 'read_event':
 read_event,
 'on_read':
 lambda e, d: all((this.read_event(e, d), this.open_external(e, d)
                   if this.props.external_viewer else None)),
 'on_tags':
 on_tags,
 'update_metatags':
 update_metatags,
 'get_item':
 get_item,
 'rate':
 gallery_rate,
 'favorite':
 lambda e, d: all((this.update_metatags({'favorite': bool(d.rating)}),
                   this.get_item(), e.preventDefault())),
 'send_to_library':
 lambda e, d: all(
     (this.update_metatags({'inbox': False}),
      this.props.remove_item(this.props.data or this.state.data)
      if this.props.remove_item else None, e.preventDefault())),
 'send_to_trash':
 lambda e, d: all(
     (this.update_metatags({'trash': True}),
      this.props.remove_item(this.props.data or this.state.data)
      if this.props.remove_item else None, e.preventDefault())),
 'restore_from_trash':
 lambda e, d: all(
     (this.update_metatags({'trash': False}), e.preventDefault())),
 'read_later':
 lambda e, d: all(