From 728c851a40146e6a9bbf8334651c14857a8301a2 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Sun, 23 Feb 2014 22:48:10 +0200 Subject: model: configurable detail fields --- acf2/model/aaa.lua | 5 ++++- acf2/model/field.lua | 8 +++++--- acf2/modules/network.lua | 6 +++++- protocol.txt | 2 ++ web/widget/table/row.js | 2 +- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/acf2/model/aaa.lua b/acf2/model/aaa.lua index dcd9a58..7a650a8 100644 --- a/acf2/model/aaa.lua +++ b/acf2/model/aaa.lua @@ -4,6 +4,7 @@ See LICENSE file for license details --]] local M = require('acf2.model') +local object = require('acf2.object') local digest = require('crypto').digest @@ -19,7 +20,9 @@ end local hash_pattern = '^(%w+)%$(%w+)%$%x+$' -local Password = require('acf2.object').class(M.String) +local Password = object.class(M.String) + +function Password:init() object.super(self, Password):init{detail=true} end function Password:normalize(context, value) if value:find(hash_pattern) then return value end diff --git a/acf2/model/field.lua b/acf2/model/field.lua index 69f36c6..76c8931 100644 --- a/acf2/model/field.lua +++ b/acf2/model/field.lua @@ -139,7 +139,8 @@ function M.Field:meta(context) end, choice ), - widget=self.widget + widget=self.widget, + detail=self.detail } ) end @@ -305,8 +306,9 @@ end M.TreeNode = class(M.Field) function M.TreeNode:init(params) - if not params.widget then params.widget = 'link' end - super(self, M.TreeNode):init(params) + super(self, M.TreeNode):init( + setdefaults(params, {detail=true, widget='link'}) + ) end function M.TreeNode:topology(context) diff --git a/acf2/modules/network.lua b/acf2/modules/network.lua index 186da13..2d962bc 100644 --- a/acf2/modules/network.lua +++ b/acf2/modules/network.lua @@ -12,7 +12,11 @@ local Host = M.new() Host.address = M.net.IPAddress{addr='ipaddr'} Host.canonical = M.String{ui_name='Canonical name'} Host.alias = M.Set{ - type=M.String, addr='alias/#', ui_name='Aliases', ui_member='Alias' + type=M.String, + addr='alias/#', + ui_name='Aliases', + ui_member='Alias', + detail=false } local Resolv = M.new() diff --git a/protocol.txt b/protocol.txt index b881a96..85804b4 100644 --- a/protocol.txt +++ b/protocol.txt @@ -57,6 +57,8 @@ resp: JSON object, with the following attributes: string, number, boolean, binary) - widget (name of client-side JS module used to display the data) + - detail: boolean indicating whether the value should be + shown only in the object-specific detailed view - editable (boolean) - condition: if present, the field is relevant only when other fields are set according to this object diff --git a/web/widget/table/row.js b/web/widget/table/row.js index 2e963c7..d4cc927 100644 --- a/web/widget/table/row.js +++ b/web/widget/table/row.js @@ -39,7 +39,7 @@ define( }, createWidget: function(name, meta, editable, removable) { - if (!meta.condition) + if (!(meta.detail || meta.condition)) return Base.createWidget.call( this, name, meta, editable, removable ); -- cgit v1.2.3