From 07658d96e47abde261740fdce418a70ab58ff0cd Mon Sep 17 00:00:00 2001
From: ezsh <ezsh.junk@gmail.com>
Date: Fri, 30 Aug 2019 13:04:53 +0200
Subject: [PATCH] Fix crash in slave listings

The getHostedSlaves property must work even if facility does not have
jobs (e.g. armory). In this case we return 0.

Fixes #1040.
---
 src/004-base/facility.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/004-base/facility.js b/src/004-base/facility.js
index 2172a12d2b7..f64d59395a5 100644
--- a/src/004-base/facility.js
+++ b/src/004-base/facility.js
@@ -331,7 +331,8 @@ App.Entity.Facilities.Facility = class {
 	/** Number of already hosted slaves
 	 * @returns {number} */
 	get hostedSlaves() {
-		return this.job().employeesIds.length;
+		const job = this.job();
+		return job ? job.employeesIds.length : 0;
 	}
 
 	get hasFreeSpace() {
-- 
GitLab