-
Notifications
You must be signed in to change notification settings - Fork 1
SubscriptionsEditor
Max S edited this page Apr 14, 2016
·
3 revisions
Just like server modules, editor modules can subscribe to different events generated by the core. At the moment there is only one interface provided with two events, _HookItemsEdit
. It is used specifically for item attributes editing and displaying.
The _HookItemsEdit.itemGetAttrName()
hook receives item attribute type and value and should return a string representation of it. If it returns null, then this module does not handle this attribute type.
Usage example (taken from item bundles module):
class BundlesEditCore extends ModuleEdit<EditServer>
implements snipe.edit.modules._HookItemsEdit
{
public function new(s: EditServer)
{
// ...
manager.subscribeModule("core/item.getAttrName", this);
}
public function itemGetAttrName(type: String, val: Dynamic): String
{
if (type == "bundleID")
{
var res = server.query("SELECT * FROM Bundles WHERE ID = " + val);
var row = res.next();
if (row == null)
row = { name: "??? NULL ???" };
return row.name;
}
return null;
}
}
The _HookItemsEdit.itemGetAttrInput()
hook receives item attribute type and value and should return a form input for it. If it returns null, then this module does not handle this attribute type.
Usage example (taken from item bundles module):
class BundlesEditCore extends ModuleEdit<EditServer>
implements snipe.edit.modules._HookItemsEdit
{
public function new(s: EditServerTest)
{
// ...
manager.subscribeModule("core/item.getAttrInput", this);
}
public function itemGetAttrInput(type: String, val: Dynamic): _BlockFormInput
{
if (type == "bundleID")
return { title: "Bundle", name: "value", type: INPUT_SELECT,
query: "SELECT ID AS Value, Name " +
"FROM Bundles ORDER BY Name",
value: val };
return null;
}
}