{# -*- coding: utf-8 -*- #} {% extends "schsys/db_field_edt.html" %} {% load exfiltry %} {% load exsyntax %} {% block pythoncodeinit %} def init_form(self): self.save_btn.Disable() self.modified = False self.tuser = wx.Timer(self) self.tuser.Start(1000) self.Bind(wx.EVT_TIMER, self.on_timer_user, self.tuser) self.EDITOR.SetSavePoint() self._insert_txt.Bind(wx.EVT_BUTTON, self.on_insert_click) self.save_btn.Bind(wx.EVT_BUTTON, self.on_click) atab=self.get_acc_tab() atab.append((0, wx.WXK_INSERT, self.on_panel_focus)) atab.append((wx.ACCEL_ALT, ord('I'), self.on_panel_focus)) self.set_acc_key_tab(self,atab) self._panel.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.on_insert_click) self._insert_icon.Bind(wx.EVT_BUTTON, self.on_insert_image_click) self.EDITOR.SetCurrentPos(0) self.EDITOR.SetSelection(0,0) wx.CallAfter(self.EDITOR.SetFocus) class ChoiceDialog(wx.Dialog): def __init__(self, parent, title, choices): wx.Dialog.__init__(self) self.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) self.Create(parent, -1, title, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE, name='dialog') self.choices = [] p = wx.Panel(self, -1, style = wx.TAB_TRAVERSAL | wx.CLIP_CHILDREN | wx.FULL_REPAINT_ON_RESIZE) self.sizer1 = wx.GridBagSizer(vgap=5, hgap=5) row = 0; for obj in choices: self.sizer1.Add( wx.StaticText(p, -1, obj['title']), (row, 0), (1,1), wx.ALIGN_LEFT | wx.ALL, 5) if len(obj['values'])>0 and type(obj['values'][0]) in (str, bytes): choice = wx.Choice(p, -1, size=(600, -1), choices = obj['values']) elif len(obj['values'])>0: choice = wx.adv.BitmapComboBox(p, -1, size=(600, -1)) for c in obj['values']: if type(c) == str: choice.Append(c) elif type(c) == bytes: choice.Append(c.decode('utf-8')) else: choice.Append(c[0], c[1]) else: choice = wx.TextCtrl(p, -1, size=(600, -1)) #wx.Choice(p, -1, size=(600, -1), choices = obj['values']) self.choices.append(choice) self.sizer1.Add(choice, (row, 1), (1,1), wx.ALIGN_LEFT | wx.ALL, 5) row+=1; self.sizer2 = wx.BoxSizer(wx.HORIZONTAL) cancel = wx.Button(p, wx.ID_CANCEL, "Cancel") ok = wx.Button(p, wx.ID_OK, "OK") self.sizer2.Add( cancel, 1, wx.EXPAND|wx.ALL, 5) self.sizer2.Add( ok, 1, wx.EXPAND|wx.ALL, 5) ok.SetDefault() #self.Bind(wx.EVT_BUTTON, self.on_ok, ok) box = wx.BoxSizer(wx.VERTICAL) box.Add(self.sizer1, 0, wx.EXPAND) box.Add(self.sizer2, 0, wx.EXPAND | wx.ALL, 5) p.SetSizerAndFit(box) self.SetClientSize(p.GetSize()) def on_ok(self, event): print(event) self.dialog = ChoiceDialog from schbuilder.autocomplete import ACTIONS self.actions = ACTIONS from django.template import Template, Context self.template_class = Template self.context_class = Context #from pytigon_lib.schhttptools.httpclient import HttpClient #self.http_client_class = HttpClient # aTable = [ # (wx.ACCEL_ALT, ord('I'), self.on_panel_focus), # (wx.ACCEL_ALT, ord(';'), self.on_), # ] # self.set_acc_key_tab(aTable) self.EDITOR.Bind(wx.EVT_KEY_DOWN, self.on_key_pressed) def on_key_pressed(self, event): if not event.AltDown() and not event.ControlDown() and ((event.KeyCode in ( ord('.'), ord(' ') ) and not event.ShiftDown()) or ((event.KeyCode in ( ord('\\'),)) and event.ShiftDown())): def _fun(): ret_str = self.on_dialog("default") if ret_str: self.insert_txt(ret_str) wx.CallAfter(_fun) event.Skip() event.Skip() def on_panel_focus(self, event): self._panel.SetFocus() def on_insert_image_click(self, event): self.insert_txt(self._icon.GetValue()) def on_dialog(self, key): dialog_title = "Chose items" parameters = [] template_str = "" return_str = "" if key == 'default': line, pos = self.EDITOR.GetCurLine() s = line[:pos].strip() if s.endswith('%%'): key = "blocks" elif s.endswith('%'): key = "tags" elif s.endswith('|'): key = 'filters' elif s.endswith('{{'): key = 'vars' elif s.endswith('object.'): key = "object fields and methods" elif s.endswith('form.'): key = "object fields and methods" elif s.endswith('object_list.'): key = "object fields and methods" else: return if key in self.actions or ( '((' in key and '))' in key ): if key in self.actions: key2 = key else: key2 = key.split('((')[1].split('))')[0].replace(' ', '_') obj = self.actions[key2] if 'title' in obj: dialog_title = obj['title'] if 'choices' in obj: parameters = obj['choices'] for obj2 in parameters: if "source_of_values" in obj2: client = wx.GetApp().get_http(self) response = client.get(self,"{{base_path}}schbuilder/autocomplete/{{object.id}}/%s/" % obj2['source_of_values']) obj3 = response.json() if len(obj3['choices'])>0: obj2['values'] = obj3['choices'][0]['values'] if 'template' in obj: template_str = obj['template'] elif key in ('object fields', 'object methods', 'object fields and methods', 'blocks', 'vars',) or key.endswith('filters') or key.endswith('tags'): client = wx.GetApp().get_http(self) response = client.get(self,"{{base_path}}schbuilder/autocomplete/{{object.id}}/%s/" % key.replace(' ', '_')) obj = response.json() if 'title' in obj: dialog_title = obj['title'] if 'choices' in obj: parameters = obj['choices'] if 'template' in obj: template_str = obj['template'] else: return key if parameters and template_str: if dialog_title or len(parameters)>1: dlg = self.dialog(self, dialog_title, parameters) dlg.CenterOnScreen() val = dlg.ShowModal() if val == wx.ID_OK: choice = [] for ctrl in dlg.choices: if type(ctrl) == wx.TextCtrl: choice.append(ctrl.GetValue()) else: choice.append(ctrl.GetStringSelection()) t = self.template_class(template_str) c = self.context_class({"choice": choice}) ret = t.render(c) return ret else: return None else: kw = parameters[0]['values'] kw.sort() self.EDITOR.SetFocus() self.EDITOR.AutoCompSetIgnoreCase(True) self.EDITOR.AutoCompShow(0, (" ").join(kw)) elif template_str: t = self.template_class(template_str) c = self.context_class({}) ret = t.render(c) return ret return return_str def on_insert_click(self, event): item = self._panel.GetSelection() if item.IsOk(): key = self._panel.GetItemText(item) ret_str = self.on_dialog(key) if ret_str: self.insert_txt(ret_str) def on_auto_comp_cmd(self, edt_ctrl, pos): ret_str = self.on_dialog("default") if ret_str: self.insert_txt(ret_str) def insert_txt(self, txt): pos = self.EDITOR.GetCurrentPos() self.EDITOR.InsertText(pos, txt) pos+=len(txt) self.EDITOR.SetCurrentPos(pos) self.EDITOR.SetFocus() {% endblock %} {% block all %} {% with form_width=800 form_height=1200 title=tab|add:"."|add:verbose_field_name %} {{ block.super }} {% endwith %} {% endblock %} {% block title %} TEM:{{object.name}} {% endblock %} {% block body %} {% if standard_web_browser %} {{ block.super }} {% else %}
{% block form_title %} Edycja: {{object.name}} [{{title}}] {% endblock %}

{% if object.get_rel_table %}
  • {{object}}
    • object fields
        {% for pos in object.get_all_table_fields %}
      • {{pos}}
        • {{pos}}
        • object.{{pos}}
        • form.fields_as_table.{{pos}}
      • {% endfor %}
    • object related fields
        {% for pos in object.get_table_rel_fields %}
      • {{pos}}
        • {{pos}}
        • object.{{pos}}
      • {% endfor %}
    • object methods
        {% for pos in object.get_table_methods %}
      • {{pos}}
        • {{pos}}
        • object.{{pos}}
      • {% endfor %}
  • {% endif %}
  • filters
    • django filters
    • pytigon filters
  • tags
    • django tags
    • pytigon tags
  • special template statements
    • {{ "^"|add:"^^"}}
    • {{ "="|add:"==>"}}
    • {{ ">"|add:">>"}}
    • {{ "<"|add:"<<"}}
    • {{ "{"|add:":}"}}
    • script language=python ...
  • targets
    • _blank
    • _parent
    • _top
    • _self
    • popup
    • popup_edit
    • popup_info
    • popup_delete
    • inline_edit
    • inline_info
    • inline_delete
    • inline
    • none
    • refresh_obj
    • refresh_page
    • refresh_app
  • template blocks
    • %% all
      • %% page_start
      • %% page_head
        • %% cache
        • %% head_start
        • %% title
        • %% css_links
        • %% css_start
        • %% css
        • %% css_end
        • %% js_scripts
          • %% js_scripts_base
        • %% js_extrascripts
        • %% python_code
        • %% icss
        • %% extra_style
        • %% extra_head
      • %% body_start
      • %% body_header
      • %% body
        • %% dialog_start
        • %% form_info
        • %% form_ok_cancel_info
        • %% form_delete
          • %% form_delete_content
          • %% form_delete_object
        • %% form_ok_cancel_del
        • %% row_edit_start
        • %% row_edit_header
        • %% row_edit_all
          • %% row_edit_form
          • %% row_edit_footer
          • %% form_ok_cancel
        • %% row_edit_end
        • %% dialog_end
        • %% login_header
        • %% login
        • %% login_footer
        • %% nav
          • %% change_password
          • %% menu_start
          • %% menu
            • %% topmenu_start
            • %% topmenu
            • %% topmenu_end
            • %% submenu_start
            • %% submenu
            • %% submenu_end
          • %% menu_end
          • %% menu2
        • %% body_init
        • %% messages
        • %% body_desktop
          • %% panel
          • %% navglobal
          • %% sidebar
          • %% content_start
          • %% all_content
            • %% content
              • %% list_page_start
              • %% list_page_header
              • %% list_page
                • %% list_content_start
                • %% list_content_header
                  • %% list_content_header_first_row
                    • %% list_content_title
                  • %% list_content_header_second_row
                    • %% list_filter_form
                      • %% form_filter
                        • %% form_content
                          • %% form_table_filter
                          • %% form_content_button
                  • %% list_content_header_third_row
                    • %% list_content_actions
                • %% list_content_body
                  • %% list_content_paginator
                  • %% list_full_row_header
                    • %% list_row_header_start
                    • %% list_row_header
                    • %% list_row_header_end
                  • %% list_table
                    • %% list_full_row
                      • %% list_row_start
                        • %% id_extra
                      • %% list_row
                      • %% list_row_end
                        • %% list_row_actions
                    • %% list_row2
                  • %% list_table_footer
                • %% list_content_footer
                • %% list_content_end
              • %% list_page_footer
              • %% list_page_end
          • %% content_end
        • %% tabs
        • %% html_widgets_init
        • %% body_footer
      • %% body_footer_scripts
      • %% page_footer
        • %% js_extrascipts_init
          • %% jquery_init
          • %% jquery_init_once
          • %% jquery_ready_all
            • %% jquery_ready_start
            • %% jquery_ready
            • %% jquery_ready_end
          • %% js_script_body
        • %% page_finish
      • %% body_end
      • %% page_end
    • {% spec '{' %} block.super {% spec '}' %}
  • vars
    • request
    • user
    • perms
    • paths
      • base_path
      • app_path
      • URL_ROOT_FOLDER
    • project
      • prj_name
      • prj_title
    • form info
      • form_add
      • form_delete
      • form_edit
      • form_ext
      • form_grid
      • form_info
      • form_list
      • show_form
      • show_title_bar
    • colors
      • color_background
      • color_background_0_5
      • color_background_0_8
      • color_background_0_9
      • color_background_1_1
      • color_background_1_2
      • color_background_1_5
      • color_body
      • color_body_0_2
      • color_body_0_5
      • color_body_0_7
      • color_body_0_9
      • color_body_1_1
      • color_body_1_3
      • color_body_1_5
      • color_body_1_8
      • color_higlight
      • color_info
      • color_shadow
    • system
      • csrf_token
      • user_agent
      • uuid
      • app_manager
      • gen_time
      • settings
      • env
    • lang
      • LANGUAGE_CODE
      • lang
      • LANGUAGES
      • LANGUAGE_BIDI
      • TIME_ZONE
    • info
      • debug
      • standard_web_browser
      • browser_type
      • client_type
      • application_type
      • autologin
      • offline_support
      • pyodide
      • default_template
      • default_template2
      • readonly
      • get
  • wizards
    • form
      • simple ((form))
      • ((two columns form))
      • ((three columns form))
      • ((advanced form))
      • ((field))
      • ((form field))
      • ((hidden field))
    • {% if object.get_rel_table %}
    • row actions
      • % row_actions
        • edit
        • delete
        • pdf
        • show related table based on field ((field_list))
        • show editor for field ((field_edit))
        • other ((action))
      • ((row_related_list))
      • ((view_row))
    • table actions
      • ((new_row))
      • ((list_action))
    • {% endif %}
    • permisions
      • check ((permision))
      • is user in group ((user_in_group))
      • user.is_authenticated
    • code blocks
      • % extends "form.html"
      • % extends "forms/tree.html"
      • % load exfiltry
      • % load exsyntax
      • block ((all))
      • block ((id_extra))
      • block ((list_row_attr))
      • block ((dialog_type))
      • block ((scroll))
      • block ((pythoncode)/)
      • snippet ((move rows))
  • {{txt|bencode}}
    {% endif %} {% endblock %} {% block content %} {% if standard_web_browser %} {% block edit_area %} {% endblock %} {% else %} {{ block.super }} {% endif %} {% endblock %}