Project

General

Profile

Patch #9225 » changeset_rea7e9f7e100db9e5ffda644296b543802039f503.diff

Jan from Planio www.plan.io, 2011-09-11 18:01

View differences:

app/views/projects/_form.rhtml
11 11
<p><%= f.text_area :description, :rows => 5, :class => 'wiki-edit' %></p>
12 12
<p><%= f.text_field :identifier, :required => true, :size => 60, :disabled => @project.identifier_frozen? %>
13 13
<% unless @project.identifier_frozen? %>
14
<%= javascript_tag "observeProjectIdentifier(#{Project::IDENTIFIER_MAX_LENGTH});observeProjectName(#{Project::IDENTIFIER_MAX_LENGTH});" %>
14 15
<br /><em><%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_project_identifier_info) %></em>
15 16
<% end %></p>
16 17
<p><%= f.text_field :homepage, :size => 60 %></p>
config/locales/de.yml
869 869
  text_tip_issue_begin_day: Aufgabe, die an diesem Tag beginnt
870 870
  text_tip_issue_end_day: Aufgabe, die an diesem Tag endet
871 871
  text_tip_issue_begin_end_day: Aufgabe, die an diesem Tag beginnt und endet
872
  text_project_identifier_info: 'Kleinbuchstaben (a-z), Ziffern und Bindestriche erlaubt.<br />Einmal gespeichert, kann die Kennung nicht mehr geändert werden.'
872
  text_project_identifier_info: 'Kleinbuchstaben (a-z), Ziffern und Bindestriche erlaubt, muss mit einem Kleinbuchstaben beginnen.<br />Einmal gespeichert, kann die Kennung nicht mehr geändert werden.'
873 873
  text_caracters_maximum: "Max. %{count} Zeichen."
874 874
  text_caracters_minimum: "Muss mindestens %{count} Zeichen lang sein."
875 875
  text_length_between: "Länge zwischen %{min} und %{max} Zeichen."
config/locales/en-GB.yml
879 879
  text_tip_issue_begin_day: task beginning this day
880 880
  text_tip_issue_end_day: task ending this day
881 881
  text_tip_issue_begin_end_day: task beginning and ending this day
882
  text_project_identifier_info: 'Only lower case letters (a-z), numbers and dashes are allowed.<br />Once saved, the identifier cannot be changed.'
882
  text_project_identifier_info: 'Only lower case letters (a-z), numbers and dashes are allowed, must start with a lower case letter.<br />Once saved, the identifier cannot be changed.'
883 883
  text_caracters_maximum: "%{count} characters maximum."
884 884
  text_caracters_minimum: "Must be at least %{count} characters long."
885 885
  text_length_between: "Length between %{min} and %{max} characters."
config/locales/en.yml
895 895
  text_tip_issue_begin_day: issue beginning this day
896 896
  text_tip_issue_end_day: issue ending this day
897 897
  text_tip_issue_begin_end_day: issue beginning and ending this day
898
  text_project_identifier_info: 'Only lower case letters (a-z), numbers and dashes are allowed.<br />Once saved, the identifier cannot be changed.'
898
  text_project_identifier_info: 'Only lower case letters (a-z), numbers and dashes are allowed, must start with a lower case letter.<br />Once saved, the identifier cannot be changed.'
899 899
  text_caracters_maximum: "%{count} characters maximum."
900 900
  text_caracters_minimum: "Must be at least %{count} characters long."
901 901
  text_length_between: "Length between %{min} and %{max} characters."
config/locales/fr.yml
867 867
  text_tip_issue_begin_day: tâche commençant ce jour
868 868
  text_tip_issue_end_day: tâche finissant ce jour
869 869
  text_tip_issue_begin_end_day: tâche commençant et finissant ce jour
870
  text_project_identifier_info: 'Seuls les lettres minuscules (a-z), chiffres et tirets sont autorisés.<br />Un fois sauvegardé, l''identifiant ne pourra plus être modifié.'
870
  text_project_identifier_info: 'Seuls les lettres minuscules (a-z), chiffres et tirets sont autorisés, doit commencer par une minuscule.<br />Un fois sauvegardé, l''identifiant ne pourra plus être modifié.'
871 871
  text_caracters_maximum: "%{count} caractères maximum."
872 872
  text_caracters_minimum: "%{count} caractères minimum."
873 873
  text_length_between: "Longueur comprise entre %{min} et %{max} caractères."
public/javascripts/application.js
243 243
	return key;
244 244
}
245 245

  
246
// Automatic project identifier generation
247
var projectIdentifierLocked = false;
248

  
249
function generateProjectIdentifier(identifierMaxLength) {
250
  var identifier = $('project_name').getValue() // project name
251
  identifier = identifier.replace(/ä/g,'ae'); // umlauts
252
  identifier = identifier.replace(/ö/g,'oe'); // umlauts
253
  identifier = identifier.replace(/ü/g,'ue'); // umlauts
254
  identifier = identifier.replace(/Ä/g,'Ae'); // umlauts
255
  identifier = identifier.replace(/Ö/g,'Oe'); // umlauts
256
  identifier = identifier.replace(/Ü/g,'Ue'); // umlauts
257
  identifier = identifier.replace(/ß/g,'ss'); // umlauts
258
  identifier = identifier.replace(/[^a-z0-9]+/gi, '-'); // non-alphanumeric => dash
259
  identifier = identifier.replace(/^[-\d]*|-*$/g, ''); // remove dashes and numbers at beginning and dashes at end
260
  identifier = identifier.toLowerCase(); // to lower
261
  identifier = identifier.substr(0,identifierMaxLength); // max characters
262
  return identifier;
263
}
264

  
265
function observeProjectName(identifierMaxLength) {
266
  var f = function() {
267
    if(!projectIdentifierLocked) {
268
      $('project_identifier').setValue(generateProjectIdentifier(identifierMaxLength));
269
    }
270
  };
271
  Event.observe('project_name', 'keyup', f);
272
}
273

  
274
function observeProjectIdentifier(identifierMaxLength) {
275
  var f = function() {
276
    if($('project_identifier').getValue() != '' && $('project_identifier').getValue() != generateProjectIdentifier(identifierMaxLength)) {
277
      projectIdentifierLocked = true;
278
    } else {
279
      projectIdentifierLocked = false;
280
    }
281
  };
282
  Event.observe('project_identifier', 'keyup', f);
283
}
284

  
246 285
function observeParentIssueField(url) {
247 286
  new Ajax.Autocompleter('issue_parent_issue_id',
248 287
                         'parent_issue_candidates',
(1-1/2)