Beispiel #1
0
    def sort_node(self):
        if not (self.app.enable_multi_sort and self.detail.display == 'short'):
            return

        sort = None

        if self.sort_xpath_function:
            sort = sx.Sort(
                text=sx.Text(xpath_function=self.sort_xpath_function),
                type='string',
            )

        if self.sort_element:
            if not sort:
                # these have to be distinguished for the UI to be able to give
                # user friendly choices
                if self.sort_element.type in ('date', 'plain'):
                    sort_type = 'string'
                else:
                    sort_type = self.sort_element.type
                sort = sx.Sort(
                    text=sx.Text(xpath_function=self.xpath_function),
                    type=sort_type,
                )

            sort.order = self.order
            sort.direction = self.sort_element.direction

        return sort
Beispiel #2
0
    def template(self):
        template = sx.GraphTemplate(
            form=self.template_form,
            graph=sx.Graph(
                type=self.column.graph_configuration.graph_type,
                series=[
                    sx.Series(
                        nodeset=s.data_path,
                        x_function=s.x_function,
                        y_function=s.y_function,
                        radius_function=s.radius_function,
                        configuration=sx.ConfigurationGroup(configs=[
                            # TODO: It might be worth wrapping
                            #       these values in quotes (as appropriate)
                            #       to prevent the user from having to
                            #       figure out why their unquoted colors
                            #       aren't working.
                            sx.ConfigurationItem(id=k, xpath_function=v)
                            for k, v in s.config.iteritems()
                        ])) for s in self.column.graph_configuration.series
                ],
                configuration=sx.ConfigurationGroup(configs=([
                    sx.ConfigurationItem(id=k, xpath_function=v) for k, v in
                    self.column.graph_configuration.config.iteritems()
                ] + [
                    sx.ConfigurationItem(
                        id=k,
                        locale_id=self.id_strings.graph_configuration(
                            self.module, self.detail_type, self.column, k))
                    for k, v in self.column.graph_configuration.
                    locale_specific_config.iteritems()
                ])),
                annotations=[
                    sx.Annotation(
                        x=sx.Text(xpath_function=a.x),
                        y=sx.Text(xpath_function=a.y),
                        text=sx.
                        Text(locale_id=self.id_strings.graph_annotation(
                            self.module, self.detail_type, self.column, i)))
                    for i, a in enumerate(
                        self.column.graph_configuration.annotations)
                ]))

        # TODO: what are self.variables and do I need to care about them here?
        # (see FormattedDetailColumn.template)

        return template
Beispiel #3
0
    def template(self):
        template = sx.Template(
            text=sx.Text(xpath_function=self.xpath_function),
            form=self.template_form,
            width=self.template_width,
        )
        if self.variables:
            for key, value in sorted(self.variables.items()):
                template.text.xpath.variables.node.append(
                    sx.XpathVariable(name=key, locale_id=value).node)

        return template
Beispiel #4
0
    def sort_node(self):
        if not (self.app.enable_multi_sort and self.detail.display == 'short'):
            return

        sort = None

        if self.sort_xpath_function:
            sort = sx.Sort(
                text=sx.Text(xpath_function=self.sort_xpath_function),
                type='string',
            )

        if self.sort_element:
            if not sort:
                # these have to be distinguished for the UI to be able to give
                # user friendly choices
                if self.sort_element.type in ('date', 'plain'):
                    sort_type = 'string'
                else:
                    sort_type = self.sort_element.type
                sort = sx.Sort(
                    text=sx.Text(xpath_function=self.xpath_function),
                    type=sort_type,
                )

            sort.order = self.order
            sort.direction = self.sort_element.direction

            # Flag field as index by making order "-2"
            # this is for the CACHE_AND_INDEX toggle
            # (I know, I know, it's hacky - blame Clayton)
            if sort.type == 'index':
                sort.type = 'string'
                sort.order = -2

        return sort
Beispiel #5
0
 def hidden_template(self):
     return sx.Template(
         text=sx.Text(xpath_function=self.sort_xpath_function),
         width=0,
     )
Beispiel #6
0
 def hidden_header(self):
     return sx.Header(
         text=sx.Text(),
         width=0,
     )
Beispiel #7
0
 def header(self):
     header = sx.Header(
         text=sx.Text(locale_id=self.locale_id),
         width=self.header_width
     )
     return header