diff --git a/CHANGELOG.md b/CHANGELOG.md index 9057e7327..da2d0e34d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Update from Maintenance > Update as usual. This release has four database change - Copy a Knowledge Base article's link from its **⋮** menu, on its page or beside it in the list - to send it to someone, or to link to it from another article. It offers the links that suit who can read it: **Copy Public Link** for an article for anyone, **Copy Portal Link** for one in the client portal, and **Copy Link** to its page here for one for agents only. A link that won't open yet is greyed out with the reason under it, such as **Publish it first** or **The public help center is off**. Agents who can read articles but not edit them get the menu with these links too. - A **Vendors** permission in Admin > Roles, for your own vendors - the ones with no client: suppliers, distributors, the colo - at **None**, **Read**, **Modify** or **Full**. Set a role to **None** to keep its agents out of your suppliers' numbers, accounts and contacts: **Vendors** in the menu opens your clients' vendors instead, your own vendors' pages and their export are refused, search leaves them out, and where a client's license, network, ticket or service names one of yours, they see only its name. A client's vendors stay with the **Clients** permission. Adding, editing and deleting your own vendors moves from **Financial** to **Vendors** too. - Link assets to each other - a label printer and its cutter, a server and its disk shelf, a desk phone and its sidecar - so a part that is swapped or sent off for repair on its own can be its own asset, with its own serial number and warranty, and still be found with what it goes on. **Link**, on the asset's new **Linked assets** card, picks from the client's other assets, of any type. A link goes both ways, each asset showing the other, and an asset can be linked to as many as it needs. Linking and unlinking are noted in both assets' History, so you can see which part was on which device and when it was swapped. A linked asset at another site says where it is, and its **⋮** menu moves either one to the other's site - nothing moves on its own. The assets list and the asset's quick look show what each asset is linked to, the client export lists the links, and assets transferred to another client together stay linked. +- A ticket's assets are one field, **Assets**, for one or several, in place of **Asset** and **Other assets** - in New Ticket, Edit, the ticket's **Change assets** window and New and Edit Recurring Ticket. The first asset picked fills in the person it's assigned to and its site, as before, and a ticket raised from an asset's page starts with that asset. On the ticket, every asset on the **Linked** card has a **×** to take it off, the first one too, the history says which assets were added and taken off, and its quick look lists them all. **Copy as a New Ticket** copies all its assets, and searching tickets finds a ticket by any of them. ### Bug Fixes @@ -38,6 +39,7 @@ Update from Maintenance > Update as usual. This release has four database change - A card is saved once per client, however often it's entered. A client who set up autopay on two recurring invoices with the same card - or added it again in the portal - ended up with the card saved twice, once for each, as Stripe gives the card a new reference each time it's entered. ITFlow now knows the same card when it comes back: the one saved card is kept, with the details just entered, and every recurring invoice it pays carries on with it. A card that is already saved twice is merged into one overnight - the copy that runs out last is kept and the autopay on the others moves to it - so you don't need to do anything, and its client isn't sent two expiry reminders for it. - Email and phone links work in Knowledge Base articles and documents - a `mailto:` or `tel:` link showed as plain text on the published article, in the client portal and on the document, while the editor still had it. Those in an article or document written in Markdown were taken out when it was saved; the database update puts them back in the ones already saved, so they don't need saving again. Email and phone links in ticket replies, such as those in an email signature, work too. - Opening one of your own vendors from a client's license or service works - it said there was nothing to see. +- A ticket's other assets show on it when its main asset was taken off - they were still on the ticket but not listed. ### Developer Updates @@ -57,6 +59,7 @@ Update from Maintenance > Update as usual. This release has four database change - `kbCopyLinks($row)` (`functions/kb.php`) gives an article's links for its readers - `[label, icon, url, why not, what it is]`, from `kbPublicUrl()`, `kbPortalArticleUrl()` and the new `kbAgentArticleUrl()` - with why one won't open yet (a draft, `kbPublicOn()` or `moduleOn('portal')` off); `kbCopyLinksMenuHtml()` makes them `.clipboardjs` dropdown items, or disabled ones with the reason in `.itflow-dropdown-why`. `agent/kb_article.php` and the rows of `agent/kb.php` show their ⋮ menu for `kbCan(1)` as well as `kbCan(2)` - with only these items for those who can't edit. - Vendors permission: `module_vendor` (database 4.4.6, module 9 on a fresh install, `setup/seed_data.php` - Technician Read, Accountant Full); 4.4.6 gives every role `max(1, its module_financial level)`. In `functions/vendor.php`, `vendorPermissionReady()` (4.4.6) switches `vendorModule(0)` from `module_financial` to `module_vendor`, and `vendorCan(0, 1)` from always-yes to the permission; `vendorEnforce(0, $level)` enforces it at every level. `vendorIsOurs($vendor_id)` (one query a page) and `vendorCanOpen($vendor_id)` decide whether a mention of a vendor opens: `vendorLink()` and the new `vendorNameHtml()` show the name without a link, and `vendorRedact($row, $vendor_id)` blanks a row's `vendor_phone`, `vendor_account_number`, `vendor_code`, `vendor_email`, contacts and hours - used by `agent/network.php`, `agent/license.php`, `agent/ticket.php`, `agent/service.php` and the network, license and service quick looks. `vendorLink()` no longer puts a client's id on a page link to one of ours. The ours list (`agent/vendors.php`), its export, the vendor quick look and global search's Vendors group check it; the side nav's Vendors goes to `vendors.php?view=clients` without it. `roleModules()` lists modules in `roleModuleInfo()`'s order, then by id. - Linked assets: `asset_links` (database 4.4.7) keeps each link as two rows, (`asset_id`, `linked_asset_id`) and the reverse, both `ON DELETE CASCADE`. `functions/asset_link.php` has `assetLinksReady()` (4.4.7), `assetLinked($asset_id)` (the client's assets, not archived), `assetLinkedNames($asset_ids)` for a list in one query, `assetLinkedTo()`, `assetLinkAdd($asset_id, $ids)` and `assetLinkRemove($asset_id, $other_id)` - each writes an `asset_history` row on both sides and `logAudit('Asset', 'Link')` or `'Unlink'` - and `assetLinkedListHtml()` for the card. The link picker (`functions/link_picker.php`) takes `asset|asset` in `LINK_PICKER_OWN`, with Support at Modify; it is kept out of `LINK_RELATIONS`, whose code assumes two different kinds. `agent/post/asset.php` adds `unlink_asset_link` and `move_linked_asset`, which sets one asset's location to the other's through `assetQuickSet()`, and `bulk_transfer_client_asset` copies the links between the assets it moves to their new copies. `clientExportLinks()` lists each pair once. +- Ticket assets: New Ticket, Edit Ticket, `agent/modals/ticket/ticket_edit_asset.php` and both recurring ticket windows post one `assets[]` multi-select, an `assets_form` marker and `asset_main`, in place of `asset_id` (`asset` in the Assets window) and `additional_assets[]`. The tables are unchanged. `ticketAssetsPosted($client_id, $main_field)` (`functions/ticket.php`) reads it - the client's own in the order posted, `asset_main` kept as `ticket_asset_id` while it is picked, else the first, the rest to `ticket_assets` - and still reads the old fields. `ticketAssetsSave()` writes both and notes the assets added and removed in `ticket_history`; `ticketOtherAssetIds()` lists the others by name; `ticketAssetsFieldHtml()` draws the field for the edit windows. `agent/js/tickets_add_modal.js` fills one `#assetSelect` and keeps the first asset picked in `#assetMain`. `remove_ticket_asset` (`delete_ticket_additional_asset` still works) takes the main asset off too, the first of the others by name taking its place. The tickets list search also looks through `ticket_assets`, and the ticket quick look (`agent/modals/ticket/ticket.php`) lists them. ## [26.12.5] diff --git a/agent/js/tickets_add_modal.js b/agent/js/tickets_add_modal.js index d7464fe9f..bf80a675c 100644 --- a/agent/js/tickets_add_modal.js +++ b/agent/js/tickets_add_modal.js @@ -38,9 +38,43 @@ } } + // The ticket's main asset, out of the ones picked in Assets (one field for one or many): the one + // it was opened for, or else the first one picked, while it is still picked - kept in assetMain, + // which the server goes by (ticketAssetsPosted() in functions/ticket.php) + let pickedBefore = []; + + function pickedAssets() { + const assets = field("assetSelect"); + if (!assets) { + return []; + } + return Array.prototype.map.call(assets.selectedOptions, function (option) { return option.value; }) + .filter(function (value) { return value && value !== '0'; }); + } + + function mainAsset() { + const picked = pickedAssets(); + const main = field("assetMain"); + if (main && picked.indexOf(main.value) !== -1) { + return main.value; + } + return picked.length ? picked[0] : ''; + } + + // After a pick: the main one stays while it is picked; else it is the first of those just + // picked - not one that happens to come first in the list + function keepMainAsset() { + const picked = pickedAssets(); + const main = field("assetMain"); + if (main && picked.indexOf(main.value) === -1) { + const added = picked.filter(function (value) { return pickedBefore.indexOf(value) === -1; }); + main.value = added.length ? added[0] : (picked.length ? picked[0] : ''); + } + pickedBefore = picked; + } + function fillFromAsset() { - const asset = field("assetSelect"); - const links = asset ? assetLinks[asset.value] : null; + const links = assetLinks[mainAsset()] || null; if (!links) { return; } @@ -71,9 +105,9 @@ return; } const contact = field("contactSelect"); - const asset = field("assetSelect"); + const asset = mainAsset(); const client_id = currentClientId(); - if (!client_id || ((!contact || contact.value === '0') && (!asset || !asset.value || asset.value === '0'))) { + if (!client_id || ((!contact || contact.value === '0') && !asset)) { box.innerHTML = ''; return; } @@ -81,7 +115,7 @@ ticket_also_open: 1, client_id: client_id, contact_id: contact ? contact.value : 0, - asset_id: asset ? asset.value : 0 + asset_id: asset || 0 }, function (data) { try { box.innerHTML = JSON.parse(data).html || ''; @@ -100,6 +134,7 @@ dropdown.addEventListener('change', function () { touched[id] = true; if (id === "assetSelect") { + keepMainAsset(); fillFromAsset(); } else if (id === "contactSelect") { fillFromContact(); @@ -204,7 +239,15 @@ return; } - dropdown.value = dropdown.dataset.selected; + // A multi-select (Assets) takes a list - "12,15" + if (dropdown.multiple) { + const wanted = dropdown.dataset.selected.split(','); + Array.prototype.forEach.call(dropdown.options, function (option) { + option.selected = wanted.indexOf(option.value) !== -1; + }); + } else { + dropdown.value = dropdown.dataset.selected; + } // What the modal was opened for counts as picked touched[dropdown.id] = true; @@ -343,11 +386,10 @@ ); } - // Populate client assets - feeds both the single asset picker and the additional assets - // multi-select from one request, as both need the same list + // Populate client assets - Assets, one field for one or many function populateAssetsDropdowns(client_id) { - if (!document.getElementById("assetSelect") && !document.getElementById("additionalAssetsSelect")) { + if (!document.getElementById("assetSelect")) { return; } @@ -364,13 +406,11 @@ // Access the data for assets (multiple) const assets = response.assets || []; - const assetSelectDropdown = resetDropdown("assetSelect", '- None -', '0'); - const additionalAssetsDropdown = resetDropdown("additionalAssetsSelect", null, null); + const assetSelectDropdown = resetDropdown("assetSelect", null, null); // Assets arrive ordered by type, so a change of type starts a new group let currentType = null; let assetGroup = null; - let additionalAssetGroup = null; assets.forEach(asset => { const assetType = asset.asset_type || 'Uncategorized'; @@ -378,7 +418,6 @@ if (assetType !== currentType) { currentType = assetType; assetGroup = appendOptionGroup(assetSelectDropdown, assetType); - additionalAssetGroup = appendOptionGroup(additionalAssetsDropdown, assetType); } assetLinks[asset.asset_id] = {contact: asset.asset_contact_id, location: asset.asset_location_id}; @@ -386,10 +425,10 @@ const assetLabel = buildAssetLabel(asset); appendGroupedOption(assetGroup, assetLabel, asset.asset_id, asset.asset_icon); - appendGroupedOption(additionalAssetGroup, assetLabel, asset.asset_id, asset.asset_icon); }); applyPreselection(assetSelectDropdown); + pickedBefore = pickedAssets(); loaded(); diff --git a/agent/modals/recurring_ticket/recurring_ticket_add.php b/agent/modals/recurring_ticket/recurring_ticket_add.php index 54e96ea0f..34a3e20f1 100644 --- a/agent/modals/recurring_ticket/recurring_ticket_add.php +++ b/agent/modals/recurring_ticket/recurring_ticket_add.php @@ -6,8 +6,8 @@ require_once '../../../includes/modal_header.php'; * New Recurring Ticket - what the tickets it raises will say (Details), how * often and from when, with their priority, category and billing (Planning), * what they are about and their tasks. Opened from a client, contact or - * asset, it starts with that filled in; picking an asset fills in the person - * it is assigned to. + * asset, it starts with that filled in. Assets is one field for one or many; + * the first asset picked fills in the person it is assigned to. */ enforceUserPermission('module_support', 2); @@ -226,21 +226,14 @@ ob_start();