HTML: Don't export others trip if no dives are selected.

Don't export 'others' trip unless there is really at least one dive to
be inserted into the 'others' group.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Gehad elrobey 2014-08-15 08:07:17 +03:00 committed by Dirk Hohndel
parent d83c36c36b
commit d2891ecbd0

View file

@ -254,18 +254,23 @@ void write_no_trip(struct membuffer *b, int *dive_no, bool selected_only, const
{
int i;
struct dive *dive;
put_format(b, "{");
put_format(b, "\"name\":\"Other\",");
put_format(b, "\"dives\":[");
bool found_sel_dive = 0;
for_each_dive (i, dive) {
// write dive if it doesn't belong to any trip and the dive is selected
// or we are in exporting all dives mode.
if (!dive->divetrip && (dive->selected || !selected_only))
if (!dive->divetrip && (dive->selected || !selected_only)) {
if (!found_sel_dive) {
put_format(b, "{");
put_format(b, "\"name\":\"Other\",");
put_format(b, "\"dives\":[");
found_sel_dive = 1;
}
write_one_dive(b, dive, photos_dir, dive_no, list_only);
}
}
put_format(b, "]},\n\n");
if (found_sel_dive)
put_format(b, "]},\n\n");
}
void write_trip(struct membuffer *b, dive_trip_t *trip, int *dive_no, bool selected_only, const char *photos_dir, const bool list_only)