示例#1
0
    def __call__(self):
        # Get the corresponding vocabulary
        vr = getVocabularyRegistry()
        vocabular = vr.get(None, self.field.vocabularyName)

        # Get the data to construct the store
        fields = ['value', 'title']
        data = list()
        for term in vocabular:
            entry = dict()
            entry['value'] = term.token
            entry['title'] = term.title
            data.append(entry)

        # Attributes for the combobox
        self.name = self.field.getName()
        self.fieldLabel = translate(self.field.title,
                                    context=self.recipe.request)
        self.emptyText = self.field.default
        self.allowBlank = not self.field.required
        self.valueField = 'value'
        self.displayField = 'title'
        self.queryMode = 'local'
        self.store = "Ext.create('Ext.data.Store', {fields: %s, data: %s})" % (json.dumps(fields, indent=' ' * 4), json.dumps(data, indent=' ' * 4))

        # Render the template
        tmpl = loader.load('combobox.json.tpl', cls=NewTextTemplate)
        stream = tmpl.generate(view=self)
        return stream.render()
示例#2
0
    def __call__(self):
        di = json.loads(super(ChoiceField, self).__call__())
        di['renderer'] = '%renderer%'
        di = json.dumps(di, indent=' ' * 4)

        # Render the template
        tmpl = loader.load('combobox_renderer.json.tpl', cls=NewTextTemplate)
        stream = tmpl.generate(view=self)
        di = di.replace('"%renderer%"', stream.render())
        return di
示例#3
0
    def __call__(self):
        di = json.loads(super(ChoiceField, self).__call__())
        di['renderer'] = '%renderer%'
        di = json.dumps(di, indent=' ' * 4)

        # Render the template
        tmpl = loader.load('combobox_renderer.json.tpl', cls=NewTextTemplate)
        stream = tmpl.generate(view=self)
        di = di.replace('"%renderer%"', stream.render())
        return di
    def __call__(self):
        di = json.loads(super(ChoiceField, self).__call__())
        # Create a combobox (same as form recipe)
        combobox = form.ChoiceField(self.recipe, self.field)()
        # But with empty fieldLabel
        combobox = combobox.replace(self.field.title, '')
        di.update(field="%combobox%")
        di['renderer'] = '%renderer%'
        di = json.dumps(di, indent=' ' * 4)
        di = di.replace('"%combobox%"', combobox)

        # Render the template
        tmpl = loader.load('combobox_renderer.json.tpl', cls=NewTextTemplate)
        stream = tmpl.generate(view=self)
        di = di.replace('"%renderer%"', stream.render())
        return di
    def __call__(self):
        di = json.loads(super(ChoiceField, self).__call__())
        # Create a combobox (same as form recipe)
        combobox = form.ChoiceField(self.recipe, self.field)()
        # But with empty fieldLabel
        combobox = combobox.replace(self.field.title, '')
        di.update(field="%combobox%")
        di['renderer'] = '%renderer%'
        di = json.dumps(di, indent=' ' * 4)
        di = di.replace('"%combobox%"', combobox)

        # Render the template
        tmpl = loader.load('combobox_renderer.json.tpl', cls=NewTextTemplate)
        stream = tmpl.generate(view=self)
        di = di.replace('"%renderer%"', stream.render())
        return di
示例#6
0
 def render_template(self, tpl_name):
     tmpl = loader.load(tpl_name, cls=NewTextTemplate)
     stream = tmpl.generate(view=self)
     return stream.render()
示例#7
0
 def render_template(self, tpl_name):
     tmpl = loader.load(tpl_name, cls=NewTextTemplate)
     stream = tmpl.generate(view=self)
     return stream.render()