List.append is not flexible enought

Bug #1225894 reported by Daniel Beck
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu HTML5 UI SDK
Triaged
Wishlist
Alexandre Abreu

Bug Description

List.append(text,label, id, onclick, user_data) allows to create a list item having the following form:

- if only text ist set: <li><a href='#'>$text</a></li>
- if text and label ist set: <li><a href='#'>text</a><label>$label</label></li>
- if text, label and id ist set: <li id="$id"><a href='#'>text</a><label>$label</label></li>

This method is however not flexible enought in practice. For example, it does not allow to add
- menu items with checkbox or switches
- menu items with image aside.
- menu items without right arrow ("i.e. withprogression")
- headers

Here are 3 suggestions that might be used instead

Alternativ 1:
===========
Declare a generic append method to add dom-element to a list:

list.append(domElement, onlick) // onclick is optional

In this case the developer has to create himself the elements (with document.createElement()).

Alternativ 2:
============
Declare several utility methods to append element:

list.appendHeader(text,onclick)
list.appendCheckboxItem(text, asideImage, onclick) //asideImage and onclick are optionals
list.appendSwitchItem(text, asideImage, onclick) //asideImage and onclick are optionals
list.appendTextItem(text, asideImage, onclick, withproggression) //asideImage, onclick, withprogression are optionals. WithProgresson packs the text element in a <a> element, so that a link is displayed on the right side.
...
list.appendItem(domElement, onclick) // generic method, like in alternativ 1.

Alternative 3:
============
Allow the declaration of list items in the list-prototype. The API could look like that:

var checkbox = List.checkboxItem('text', onclick);
var switch = List.switchItem('text', onclick);
var text = List.textItem('text', onclick);
var header = List.header('text',onclick);

list.append(header, checkbox, switch, text);

Adnane Belmadiaf (daker)
Changed in ubuntu-html5-theme:
status: New → Triaged
importance: Undecided → Medium
assignee: nobody → Alexandre Abreu (abreu-alexandre)
David Barth (dbarth)
Changed in ubuntu-html5-theme:
importance: Medium → Wishlist
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.