From cbf63d3f56f278131b284e6133baea61ae46ce5d Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Fri, 16 May 2025 11:01:22 -0500 Subject: [PATCH] misc ... refactoring --- cms/static/js/forms.js | 60 ++++++++++++++++++++++++++++++++++++++++++ cms/static/js/menu.js | 9 ++++--- readme.md | 1 + 3 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 cms/static/js/forms.js diff --git a/cms/static/js/forms.js b/cms/static/js/forms.js new file mode 100644 index 0000000..f068d7a --- /dev/null +++ b/cms/static/js/forms.js @@ -0,0 +1,60 @@ +/*** + * + * This file build forms from a given set of specifications (in JSON) format + */ + +var _form =function(_id,_data) { + this._data = _data // {input,defaults,choices} + this._id = _id + // + // let's clean up the data : + this._data.defaults = (this._data.defaults == null)? {}:this._data.defaults + this._data.choices = (this._data.choices == null)?{}: this._data.choices + this.render = function (){ + _title = $('
').html(this._id).addClass(this._id) + var _input = this._data.input + var _defaults = this._data.defaults + var _choices = this._data.choices + + _input.forEach (_label=>{ + _value = _defaults[_label] + if (_choices[_label]){ + + }else{ + // + // This + + _input = this.get.input(_label,_value) + } + + }) + } + + this.get = {} + this.get.input = function (label,value){ + _frame = $('
') + _label = $('
').html(label) + _input = $('').attr('placeholder',label.0.replace(/_/,' ').trim()).addClass("input-"+label) + $(_input)[0].data = label + if (value){ + $(_input).val(value) + } + _frame.append(_label,_input) + return _frame + } + this.get.choice= function (label,_default,choices) { + var _input = this.get.input(label,_default) + $(input).addClass("hidden-input") + $(_input).on('click',function (){ + + }) + _pane = $('
') + choices.forEach(_value=>{ + _option = $('
').addClass("option").addClass("option-"+_value) + $(_pane).append(_option) + }) + _pane.append(_input,choices) + _frame = $('
').append(_pane) + return _frame + } +} \ No newline at end of file diff --git a/cms/static/js/menu.js b/cms/static/js/menu.js index 04a2f1b..794efdb 100644 --- a/cms/static/js/menu.js +++ b/cms/static/js/menu.js @@ -299,7 +299,7 @@ var QCMSBasic= function(_layout,_context,_clickEvent) { } } -var QCMSTabs = function(_layout,_context,_clickEvent){ +var QCMSTabs = function(_layout,_context,_id){ // // This object will make tabs in the area of the menu // @TODO: we can parameterize where the menu is made to improve flexibility @@ -308,6 +308,7 @@ var QCMSTabs = function(_layout,_context,_clickEvent){ this.tabs.className = 'tabs' this._context = _context this._layout = _layout + this._target = (_id == null)?'.main .menu':_id this._make = function (text,_item,_event){ var text = text.trim().replace(/(_|-)/ig,' ').trim() var _context = this._context; @@ -364,9 +365,9 @@ var QCMSTabs = function(_layout,_context,_clickEvent){ }) this.tabs.className = 'tabs' - $('.main .menu').append(this.tabs) - $('.main .menu').css({'border':'1px solid transparent'}) - $('.main .menu').css({'grid-template-columns':'64px auto'}) + $(this._target).append(this.tabs) + $(this._target).css({'border':'1px solid transparent'}) + $(this._target).css({'grid-template-columns':'64px auto'}) } // // We need to load the pages here ... diff --git a/readme.md b/readme.md index 9bd0345..11855bb 100644 --- a/readme.md +++ b/readme.md @@ -38,6 +38,7 @@ The content is created in ./qcms-demo/www/html Things to update with qcms runner : + - system.icon location, when creating a project - applying themes - upgrade all plugins to return data-type ?