Remove old/unwanted Vue.js index experiment, for Users table

This commit is contained in:
Lance Edgar 2020-03-15 09:40:11 -05:00
parent 59cae7d207
commit 413e9b0f1e
4 changed files with 3 additions and 195 deletions

View file

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8; -*-
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2017 Lance Edgar # Copyright © 2010-2020 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -51,8 +51,3 @@ class ConfigExtension(BaseExtension):
# provide default theme selection # provide default theme selection
config.setdefault('tailbone', 'themes', 'default, falafel') config.setdefault('tailbone', 'themes', 'default, falafel')
config.setdefault('tailbone', 'themes.expose_picker', 'true') config.setdefault('tailbone', 'themes.expose_picker', 'true')
def expose_vuejs_experiments(config):
return config.getbool('tailbone', 'expose_vuejs_experiments',
default=False)

View file

@ -1,11 +0,0 @@
## -*- coding: utf-8; -*-
<%inherit file="/principal/index.mako" />
<%def name="context_menu_items()">
${parent.context_menu_items()}
% if expose_vuejs_experiments:
<li>${h.link_to("Vue.js Index", url('{}.vue_index'.format(route_prefix)))}</li>
% endif
</%def>
${parent.body()}

View file

@ -1,145 +0,0 @@
## -*- coding: utf-8; -*-
<%inherit file="/users/index.mako" />
## <%def name="head_tags()">
## ${parent.head_tags()}
## ## TODO: this is needed according to Bulma docs?
## ## https://bulma.io/documentation/overview/start/#code-requirements
## <meta name="viewport" content="width=device-width, initial-scale=1">
## </%def>
<%def name="extra_javascript()">
${parent.extra_javascript()}
<!-- vue -->
${h.javascript_link('https://cdn.jsdelivr.net/npm/vue')}
<!-- vuex -->
${h.javascript_link('https://unpkg.com/vuex')}
<!-- vue-tables-2 -->
${h.javascript_link('https://cdn.jsdelivr.net/npm/vue-tables-2@1.4.70/dist/vue-tables-2.min.js')}
## ${h.javascript_link(request.static_url('tailbone:static/js/lib/vue-tables.js'))}
<!-- bulma -->
${h.stylesheet_link('https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.min.css')}
<!-- fontawesome -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
<style type="text/css">
/* workaround for header logo, needed for Bulma (ugh) */
## TODO: this img should be 49px for height, what gives here?
.home img { height: 59px; }
</style>
</%def>
<div id="vue-app">
## TODO: need to make endpoint a bit more configurable somehow
<v-server-table name="users" url="/api/users" :columns="columns" :options="options">
## TODO: make URLs more flexible / configurable... also perms?
% if request.has_perm('users.view'):
<span slot="username" slot-scope="props"><a :href="'/users/'+props.row.uuid">{{ props.row.username }}</a></span>
<span slot="person_display_name" slot-scope="props"><a :href="'/users/'+props.row.uuid">{{ props.row.person_display_name }}</a></span>
% endif
## TODO: why on earth doesn't it render bool as string by default?
<span slot="active" slot-scope="props">{{ props.row.active }}</span>
## TODO: make URLs more flexible / configurable... also perms?
<span slot="actions" slot-scope="props">
% if request.has_perm('users.view'):
<a :href="'/users/'+props.row.uuid">View</a>
% endif
% if request.has_perm('users.edit'):
| <a :href="'/users/'+props.row.uuid+'/edit'">Edit</a>
% endif
</span>
</v-server-table>
</div>
<script type="text/javascript">
// Vue.use(Vuex);
var store = new Vuex.Store({
// state: {
// appVersion: null,
// // TODO: is this really needed or can we just always check appsettings?
// production: appsettings.production,
// user: null,
// pageTitle: null
// },
// mutations: {
// setAppVersion(state, payload) {
// state.appVersion = payload;
// },
// setPageTitle(state, payload) {
// state.pageTitle = payload;
// },
// setUser(state, payload) {
// state.user = payload;
// }
// },
// actions: {
// }
})
Vue.use(VueTables.ServerTable, {
sortIcon: {
is: 'fa-sort',
base: 'fas',
up: 'fa-sort-up',
down: 'fa-sort-down'
}
}, true, 'bulma', 'default');
<%
columns = [
'username',
'person_display_name',
'active',
]
if request.has_any_perm('users.view', 'users.edit'):
columns.append('actions')
%>
var app = new Vue({
el: '#vue-app',
store: store,
data: {
columns: ${json.dumps(columns)|n},
options: {
columnsDropdown: true,
filterable: false,
headings: {
person_display_name: "Person"
},
sortable: [
'username',
'person_display_name',
'active'
],
orderBy: {
column: 'username',
ascending: true
},
perPageValues: [10, 25, 50, 100, 200],
// preserveState: true,
saveState: true,
// TODO: why doesn't local storage work? but alas, table does not
// properly submit the 'orderBy' param, and results aren't paginated
storage: 'session'
}
}
});
// $.get('/api/users', {sort: 'username|desc', page: 1, per_page: 10}, function(data) {
// app.users = data.users;
// });
</script>

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2019 Lance Edgar # Copyright © 2010-2020 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -42,7 +42,6 @@ from tailbone import forms
from tailbone.db import Session from tailbone.db import Session
from tailbone.views import MasterView from tailbone.views import MasterView
from tailbone.views.principal import PrincipalMasterView, PermissionsRenderer from tailbone.views.principal import PrincipalMasterView, PermissionsRenderer
from tailbone.config import expose_vuejs_experiments
class UsersView(PrincipalMasterView): class UsersView(PrincipalMasterView):
@ -133,16 +132,6 @@ class UsersView(PrincipalMasterView):
g.set_link('last_name') g.set_link('last_name')
g.set_link('display_name') g.set_link('display_name')
def template_kwargs_index(self, **kwargs):
kwargs['expose_vuejs_experiments'] = expose_vuejs_experiments(self.rattail_config)
return kwargs
def vue_index(self):
if not expose_vuejs_experiments(self.rattail_config):
raise self.notfound()
return self.render_to_response('vue_index', {})
def unique_username(self, node, value): def unique_username(self, node, value):
query = self.Session.query(model.User)\ query = self.Session.query(model.User)\
.filter(model.User.username == value) .filter(model.User.username == value)
@ -408,10 +397,6 @@ class UsersView(PrincipalMasterView):
@classmethod @classmethod
def defaults(cls, config): def defaults(cls, config):
# TODO: probably should stop doing this one
cls._vue_index_defaults(config)
cls._user_defaults(config) cls._user_defaults(config)
cls._principal_defaults(config) cls._principal_defaults(config)
cls._defaults(config) cls._defaults(config)
@ -430,22 +415,6 @@ class UsersView(PrincipalMasterView):
config.add_tailbone_permission(permission_prefix, '{}.edit_roles'.format(permission_prefix), config.add_tailbone_permission(permission_prefix, '{}.edit_roles'.format(permission_prefix),
"Edit the Roles to which a {} belongs".format(model_title)) "Edit the Roles to which a {} belongs".format(model_title))
@classmethod
def _vue_index_defaults(cls, config):
"""
Provide default configuration for the "Vue.js index" view. This was
essentially an experiment and probably should be abandoned.
"""
rattail_config = config.registry.settings.get('rattail_config')
route_prefix = cls.get_route_prefix()
url_prefix = cls.get_url_prefix()
permission_prefix = cls.get_permission_prefix()
# vue-index
config.add_route('{}.vue_index'.format(route_prefix), '{}/vue-index/'.format(url_prefix))
config.add_view(cls, attr='vue_index', route_name='{}.vue_index'.format(route_prefix),
permission='{}.list'.format(permission_prefix))
class UserEventsView(MasterView): class UserEventsView(MasterView):
""" """