<commit_before>import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Router } from 'meteor/iron:router';
import { Template } from 'meteor/templating';
import Groups from '/imports/api/groups/groups.js';

import UserSearchPrefix from '/imports/utils/user-search-prefix.js';
import ShowServerError from '/imports/ui/lib/show-server-error.js';
import { AddMessage } from '/imports/api/messages/methods.js';

import '/imports/ui/components/buttons/buttons.js';

import './group-settings.html';

Template.groupSettings.onCreated(function() {
	var instance = this;

	instance.busy(false);

	instance.userSearch = new ReactiveVar('');

	instance.autorun(function() {
		var search = instance.userSearch.get();
		if (search.length > 0) {
			Meteor.subscribe('userSearch', search);
		}
	});
});

Template.groupSettings.helpers({
	foundUsers: function() {
		var instance = Template.instance();

		var search = instance.userSearch.get();
		if (search === '') return false;

		var group = Groups.findOne(Router.current().params._id);
		return UserSearchPrefix(search, { exclude: group.members, limit: 30 });
	},

	kioskEventURL: function() {
		return Router.routes.kioskEvents.url({}, { query: {group: this._id} });
	},
	timetableURL: function() {
		return Router.routes.timetable.url({}, { query: {group: this._id} });
	},
	scheduleURL: function() {
	return Router.routes.frameSchedule.url({}, { query: {group: this._id} });
	},
	frameEventsURL: function() {
		return Router.routes.frameEvents.url({}, { query: {group: this._id} });
	},
	frameWeekURL: function() {
		return Router.routes.frameWeek.url({}, { query: {group: this._id} });
	},
	frameCalendarURL: function() {
		return Router.routes.frameCalendar.url({}, { query: {group: this._id} });
	},
	frameListURL: function() {
		return Router.routes.frameList.url({}, { query: {group: this._id} });
	},
});

Template.groupSettings.events({
	'keyup .js-search-users': function(event, instance) {
		instance.userSearch.set(instance.$('.js-search-users').val());
	},

	'click .js-member-add-btn': function(event, instance) {
		var memberId = this._id;
		var groupId = Router.current().params._id;
		Meteor.call("updateGroupMembership", memberId, groupId, true, function(err) {
			if (err) {
				ShowServerError('Could not add member', err);
			} else {
				AddMessage("\u2713 " + mf('_message.saved'), 'success');
			}
		});
	},

	'click .js-member-remove-btn': function(event, instance) {
		var memberId = ''+this;
		var groupId = Router.current().params._id;
		Meteor.call("updateGroupMembership", memberId, groupId, false, function(err) {
			if (err) {
				ShowServerError('Could not remove member', err);
			} else {
				AddMessage("\u2713 " + mf('_message.removed'), 'success');
			}
		});
	},

	'click .js-group-edit-save': function(event, instance) {
		event.preventDefault();

		var parentInstance = instance.parentInstance(); // Not available in callback

		instance.busy('saving');
		const changes = {
			logoUrl: instance.$('.js-logo-url').val(),
			backgroundUrl: instance.$('.js-background-url').val()
		};
		Meteor.call("saveGroup", instance.data.group._id, changes, function(err) {
			instance.busy(false);
			if (err) {
				ShowServerError('Could not save settings', err);
			} else {
				AddMessage("\u2713 " + mf('_message.saved'), 'success');
				parentInstance.editingSettings.set(false);
			}
		});
	},

	'click .js-group-edit-cancel': function(event, instance) {
		instance.parentInstance().editingSettings.set(false);
	}
});
<commit_msg>fix courselist frame link<commit_after>import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Router } from 'meteor/iron:router';
import { Template } from 'meteor/templating';
import Groups from '/imports/api/groups/groups.js';

import UserSearchPrefix from '/imports/utils/user-search-prefix.js';
import ShowServerError from '/imports/ui/lib/show-server-error.js';
import { AddMessage } from '/imports/api/messages/methods.js';

import '/imports/ui/components/buttons/buttons.js';

import './group-settings.html';

Template.groupSettings.onCreated(function() {
	var instance = this;

	instance.busy(false);

	instance.userSearch = new ReactiveVar('');

	instance.autorun(function() {
		var search = instance.userSearch.get();
		if (search.length > 0) {
			Meteor.subscribe('userSearch', search);
		}
	});
});

Template.groupSettings.helpers({
	foundUsers: function() {
		var instance = Template.instance();

		var search = instance.userSearch.get();
		if (search === '') return false;

		var group = Groups.findOne(Router.current().params._id);
		return UserSearchPrefix(search, { exclude: group.members, limit: 30 });
	},

	kioskEventURL: function() {
		return Router.routes.kioskEvents.url({}, { query: {group: this._id} });
	},
	timetableURL: function() {
		return Router.routes.timetable.url({}, { query: {group: this._id} });
	},
	scheduleURL: function() {
	return Router.routes.frameSchedule.url({}, { query: {group: this._id} });
	},
	frameEventsURL: function() {
		return Router.routes.frameEvents.url({}, { query: {group: this._id} });
	},
	frameWeekURL: function() {
		return Router.routes.frameWeek.url({}, { query: {group: this._id} });
	},
	frameCalendarURL: function() {
		return Router.routes.frameCalendar.url({}, { query: {group: this._id} });
	},
	frameListURL: function() {
		return Router.routes.frameCourselist.url({}, { query: {group: this._id} });
	},
});

Template.groupSettings.events({
	'keyup .js-search-users': function(event, instance) {
		instance.userSearch.set(instance.$('.js-search-users').val());
	},

	'click .js-member-add-btn': function(event, instance) {
		var memberId = this._id;
		var groupId = Router.current().params._id;
		Meteor.call("updateGroupMembership", memberId, groupId, true, function(err) {
			if (err) {
				ShowServerError('Could not add member', err);
			} else {
				AddMessage("\u2713 " + mf('_message.saved'), 'success');
			}
		});
	},

	'click .js-member-remove-btn': function(event, instance) {
		var memberId = ''+this;
		var groupId = Router.current().params._id;
		Meteor.call("updateGroupMembership", memberId, groupId, false, function(err) {
			if (err) {
				ShowServerError('Could not remove member', err);
			} else {
				AddMessage("\u2713 " + mf('_message.removed'), 'success');
			}
		});
	},

	'click .js-group-edit-save': function(event, instance) {
		event.preventDefault();

		var parentInstance = instance.parentInstance(); // Not available in callback

		instance.busy('saving');
		const changes = {
			logoUrl: instance.$('.js-logo-url').val(),
			backgroundUrl: instance.$('.js-background-url').val()
		};
		Meteor.call("saveGroup", instance.data.group._id, changes, function(err) {
			instance.busy(false);
			if (err) {
				ShowServerError('Could not save settings', err);
			} else {
				AddMessage("\u2713 " + mf('_message.saved'), 'success');
				parentInstance.editingSettings.set(false);
			}
		});
	},

	'click .js-group-edit-cancel': function(event, instance) {
		instance.parentInstance().editingSettings.set(false);
	}
});

{'fraction_non_alphanumeric': 0.17895329206527855, 'fraction_numerical': 0.004220596510973551, 'mean_word_length': 4.393778452200303, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2365199', 'n_tokens_mistral': 2549, 'n_tokens_neox': 2340, 'n_words': 449}