def update_metatags(mtags): if this.state.data: client.call_func("update_metatags", None, item_type=this.state.item_type, item_id=this.state.data.id, metatags=mtags) d = utils.JSONCopy(this.state.data) d.metatags = dict(d.metatags) d.metatags.update(mtags) this.setState({'data': d})
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})
def gallery_on_update(p_props, p_state): if p_props.location.pathname != this.props.location.pathname: this.setState({'id': int(this.props.match.params.item_id)}) if any((p_state.id != this.state.id, )): this.get_item() if any((p_state.data != this.state.data, )): this.update_menu() if this.props.location: g = utils.JSONCopy(this.state.data) if g.tags: del g['tags'] if g.taggable: del g['taggable'] this.props.location.state.gallery = g this.props.history.js_replace(this.props.location) if any((p_state.edit_mode != this.state.edit_mode, )): this.update_menu()
def collection_on_update(p_props, p_state): if p_props.location.pathname != this.props.location.pathname: this.setState({'id': int(this.props.match.params.item_id)}) if any(( p_state.id != this.state.id, )): this.get_item() if any(( p_state.data != this.state.data, )): this.update_menu() if this.props.location: c = utils.JSONCopy(this.state.data) this.props.location.state.collection = c this.props.history.js_replace(this.props.location) if any(( p_state.edit_mode != this.state.edit_mode, )): this.update_menu()
def on_gallery_update(g): new_data = utils.JSONCopy(this.state.data) new_data.gallery = g this.setState({'data': new_data})
def update_options(key, value): d = utils.JSONCopy(this.state.options) d[key] = value this.setState({'options': d})
def creategallery_update(p_p, p_s): if p_s.gallery_data != this.state.gallery_data: data = this.state.data or {} data['gallery'] = this.state.gallery_data this.setState({'data': utils.JSONCopy(data)})
Titles = createReactClass({ 'displayName': 'Titles', 'getInitialState': lambda: { 'data': this.props.data or [], }, 'update_title': update_title, 'update_language': update_title_language, 'on_create_item': lambda: all((this.props.data.append({}), this.setState({'data': utils.JSONCopy(this.props.data)}))), # 'cancel_create_item': lambda: this.setState({'create_item': False}), 'update_data': utils.update_data, 'on_remove': remove_title, 'componentDidUpdate': titles_update, 'render': titles_render }) __pragma__("kwargs") def artist_update_data(*args, **kwargs):
key=n + u.js_name) ) if this.props.edit_mode: els.append(e(ui.List.Item, e(ui.List.Icon, js_name="plus", onClick=this.on_create_item, color="green", link=True), key="new") ) return e(ui.List, this.props.children if this.props.children else els, size=this.props.size, relaxed=this.props.relaxed, className=this.props.className, as_=this.props.as_) URLs = createReactClass({ 'displayName': 'URLs', 'getInitialState': lambda: { 'data': this.props.data or [], }, 'on_update': update_url, 'on_create_item': lambda: all((this.props.data.append({}), this.setState({'data': utils.JSONCopy(this.props.data)}))), 'update_data': utils.update_data, 'on_remove': remove_url, 'componentDidUpdate': urls_update, 'render': urls_render })
'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(), )), 'componentDidUpdate': collection_on_update, 'render': page_render })
(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) }), )), '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))), 'on_read':
def update_data(g): new_g = utils.JSONCopy(g) this.setState({'data': new_g}) if this.props.on_data_update: this.props.on_data_update(new_g)